Article View: comp.bugs.sys5
Article #196Re: INT_MIN bug
From: Doug Gwyn
Date: Mon, 23 Jul 1990 17:58
Date: Mon, 23 Jul 1990 17:58
19 lines
1533 bytes
1533 bytes
In article <9007181749.AA16031@mindcrf.mindcraft.com> karish@mindcrf.UUCP writes: >In article <1295@tuewsd.win.tue.nl> wsinpdb@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.
Technical Details
Message-ID:
<13383@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!haven!adm!smoke!gwynReferences:
<1295@tuewsd.win.tue.nl> <9007181749.AA16031@mindcrf.mindcraft.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.bugs.sys5 Subject: Re: INT_MIN bug Keywords: negative constants, overflow Message-ID: <13383@smoke.BRL.MIL> Date: 23 Jul 90 17:58:23 GMT References: <1295@tuewsd.win.tue.nl> <9007181749.AA16031@mindcrf.mindcraft.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 19