Robert,
And if you don't cast it, you will leave it up to the compiler, thus the
behavior becomes compiler specfic, will it cast the unsigned to a signed or
will it cast the signed to an unsigned value. What does happen, if you don't
cast, and assign my_signed to my_unsigned if my_unsinged > INT_MAX ?. What
it boils down to is that you have need have to perform assert, even when you
don't cast. And I agree, it is best to resolve the signed/unsigned conflicts
rather than casting the warning away.

Albert


----- Original Message -----
From: "Robert Hegemann" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, September 17, 2000 6:50 PM
Subject: [MP3 ENCODER] castings


Hi all,

I see a tendency that compiler warnings get casted away.
The problem is, that these castings make your compiler
happy, but there is a high potential that this only covers
BUGS. Everytime someone will cast away compiler warnings
he should back up his change with an assertion!

For example, casting an unsigned to a signed int:

assert(my_unsinged <= INT_MAX);
my_signed = (int)my_unsigned;

Also, don't get into the habit of becoming a slave
of your compiler.

If there are ambiguities, try to solve them without castings.


Ciao Robert


--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to