F
Francois Grieu
A true story: one C compiler for an embedded processor that
I use claims " ANSI '89 compatibility ". But when I upgraded
from version 2.30 to 2.30.01, some previously working code
misbehaved. After reduction, it turns out that for
unsigned char foo = 0x400000*3/0x40000;
the former compiler set foo to 0x30, and the later 0xF0.
All versions of the compiler agree on
foo = 0x400000*3L/0x40000; /* 0x30 */
foo = 0xC00000/0x40000; /* 0x30 */
foo = 0x400000*3>>18; /* 0x30 */
foo = 0x40000*3/0x4000; /* 0x30 */
The outcome of <limits.h> is that
INT_MAX is 32767
LONG_MAX is 0x7fffffff
but it turns out the compiler has a an extra non-standard
"short long" integer type, and
SLONG_MAX is 0x7fffff
Is the newer compiler wrong ?
Francois Grieu
I use claims " ANSI '89 compatibility ". But when I upgraded
from version 2.30 to 2.30.01, some previously working code
misbehaved. After reduction, it turns out that for
unsigned char foo = 0x400000*3/0x40000;
the former compiler set foo to 0x30, and the later 0xF0.
All versions of the compiler agree on
foo = 0x400000*3L/0x40000; /* 0x30 */
foo = 0xC00000/0x40000; /* 0x30 */
foo = 0x400000*3>>18; /* 0x30 */
foo = 0x40000*3/0x4000; /* 0x30 */
The outcome of <limits.h> is that
INT_MAX is 32767
LONG_MAX is 0x7fffffff
but it turns out the compiler has a an extra non-standard
"short long" integer type, and
SLONG_MAX is 0x7fffff
Is the newer compiler wrong ?
Francois Grieu