This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with cast from double to unsigned short int


Hi Thomas,

I presume that short on your platform is 16-bit.

Also, I presume that this line...

is = (short int) ((double)(ius));

...yields correct results when ius is 0 through 32767.

Is that correct?

I think that when "ius > 32767" on such a platform, the result is undefined
behavior.

If I am correct:  as such, -32768 is a reasonable value.  So is -13000.

But I may be mistaken, and hopefully someone can site ISO 14882
chapter/verse.

> Is this a bug with gcc?

No, I think it is a bug in the code.

Sincerely,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]