This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Traditional numbers
- To: gcc at gcc dot gnu dot org
- Subject: Re: Traditional numbers
- From: James Grosbach <james dot grosbach at microchip dot com>
- Date: Mon, 30 Jul 2001 08:08:43 -0700
- References: <20010727183548.B23588@daikokuya.demon.co.uk>
On Fri, Jul 27, 2001 at 06:35:48PM +0100, Neil Booth wrote:
> int main()
> {
> #if 0xffffffff < 0
> puts("cpp:negative");
> #else
> puts("cpp:positive");
> #endif
> puts(0xffffffff < 0 ? "c:negative" : "c:positive");
> return 0;
> }
> bash$ gcc3 -traditional a.c && ./a.out
> cpp:positive
> c:negative
>
> Does the list agree that the above behaviour is a bug?
Yes. According to my understanding of the standard, the compiler
is in error. The integer constant should be of the first type
from the following list into which the value will fit: int,
unsigned int, long int, unsigned long int. The value 0xffffffff
will not fit in a signed 32-bit type, so the type of the
constant is unsigned int, and the comparison should yield
false.
-jim grosbach