This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: warning: decimal constant is so large that it is unsigned
- To: "Pergola, Michael" <MichaelPergola at Danfoss dot com>
- Subject: Re: warning: decimal constant is so large that it is unsigned
- From: 'Neil Booth' <neil at daikokuya dot demon dot co dot uk>
- Date: Fri, 26 Oct 2001 20:01:46 +0100
- Cc: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>,"Tom Englert (E-mail)" <EnglertTom at aol dot com>
- References: <E1836A7F3557D311A14000805F9F36FCD4E507@usdfo011.usac.danfoss.net>
Pergola, Michael wrote:-
> Neil,
>
> Thanks for the prompt reply. If gcc is truly taking this as two tokens,
> then,
> yes it would be a help in telling me that 2147483648 is really too large for
>
> an int assignment. The question would then be, should it be represented as
> its hexadecimal equivalent 0x80000000? And why would gcc take this as
> two tokens and not keep the negative sign with the value?
That's just the rules of C - "-" is an operator and not part of a
number. So what looks like a number is really an operator plus a
number.
The number is 2147483648, and that's too big for the standard "int" so
GCC has to force its type to "unsigned int". Hence the warning.
The best way to fix it is to use
-2147483647 - 1
which doesn't suffer from overflow issues. 8-)
Neil.