INT_MIN bug

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Jul 24 03:58:23 AEST 1990


In article <9007181749.AA16031 at mindcrf.mindcraft.com> karish at mindcrf.UUCP writes:
>In article <1295 at tuewsd.win.tue.nl> wsinpdb at lso.win.tue.nl (Paul de Bra) writes:
>>#define INT_MIN 	-2147483648
>>#define LONG_MIN	-2147483648L
>>which, according to K&R (second edition) are unsigned (constant) expressions
>>in ANSI C.
>K&R II, section B11, does not say that the values must be unsigned.
>The C Standard specifically requires that they have the appropriate signs:
>    2.2.4.2, Numerical Limits

You missed de Bra's point.  On the 386, the integer constant written
"2147483648" has type (unsigned long int), as specified in 3.1.3.2
Semantics.  The constant expression consisting of "-" followed by
such a numeric string" therefore also has type (unsigned long int).
Since 2.2.4.2.1 specifies that the values of the macros shall be
replaced by expressions that have the same type as would an expression
that is an object of the corresponding type converted according to the
integral promotions, the types should be (int) and (long int),
respectively; thus the implementation is providing incorrect types.



More information about the Comp.bugs.sys5 mailing list