This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Traditional numbers


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]