warning message "decimal constant is unsigned only in ISO C90"
Richard Earnshaw
rearnsha@arm.com
Wed Apr 2 16:39:00 GMT 2003
> I'm getting this warning when trying to initialize a signed int with
> the most natural form of a constant for the maximum negative value:
>
> $ cat x.c
> signed int maxneg1 = -2147483648; /* This gives a warning */
> signed int maxneg2 = -2147483647 - 1; /* This is OK */
> signed int maxneg3 = 0x80000000; /* This is also OK */
>
> $ /usr/local/sourceware/bin/gcc -c x.c
> x.c:1: warning: this decimal constant is unsigned only in ISO C90
>
> $ /usr/local/sourceware/bin/gcc --v
> Reading specs from /links1/usr/local/sourceware/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
> Configured with: /src/sourceware/gcc/gcc/configure -v --prefix=/usr/local/sourceware --cache-file=config.cache --enable-languages=c,c++
> Thread model: posix
> gcc version 3.4 20030401 (experimental)
>
> Is this some sort of bug or just a quirk of how integer constants are
> converted from external to internal format on a 32 bit two's
> complement machine?
It's because c90 says that the constant is 2147483648 (which is not
representable as a signed 32-bit value). To that constant you've then
applied the negation operation.
c90 doesn't have negative constants, only positive ones that have been
negated...
R.
More information about the Gcc-bugs
mailing list