Constant overflow
Michael Meissner
meissner at xyzzy.UUCP
Tue Mar 8 05:35:44 AEST 1988
In article <2747 at mmintl.UUCP> franka at mmintl.UUCP (Frank Adams) writes:
| Try this one on your favorite C compiler. So far, every one I've tried
| (including lint) has had no complaint:
|
| long i = 9876543210L;
|
| (The problem, of course, is that that number doesn't fit in 32 bits. If
| your compiler has a word size of more than 32 bits, try something big
| enough to overflow whatever it uses.)
Ok, on the Data General C compiler, you get:
Error 104 severity 2 beginning on line 1 (Line 1 of file foo.c)
long i = 9876543210L;
^
The int constant "9876543210L" could not fit into 32 bits without
a loss of precision. The compiler truncated it on the left.
--
Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner
Arpa/Csnet: meissner at dg-rtp.DG.COM
More information about the Comp.lang.c
mailing list