[windev] offtopic C cast
Paul Stephenson
paul.a.stephenson at ntlworld.com
Fri Jan 23 13:14:57 GMT 2009
Hello.
Apologies for the offtopic post but I was interested if any of you clever
guys out there had a view on what the compiler might be doing here. I know
the casting is horrible - I didn't write it.
I am developing embedded code using an IAR toolset and after upgrading to
version 3.30A of the C compiler found the following compiler bug! after
reducing the code to the minimum.
unsigned char c1=0, c2=15;
unsigned long x8 = 60000ul * ((unsigned long) (c1*256 + c2)); // not work
(= 4294884256)
unsigned long x9 = 60000ul * (unsigned long)((unsigned long) (c1*256 +
c2)); // not work (= 4294884256)
unsigned long x10 = ((unsigned long) (c1*256 + c2)); // ok (=15)
unsigned long x11 = 60000ul * ((unsigned long) (c1*256ul + c2)); // ok (=
900000)
--
c1 and c2 defined as 16bit int also does not work
Thanks in advance.
Paul
_________________________
Paul Stephenson
More information about the Windev
mailing list