help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ bug?


From: Bernd Strieder
Subject: Re: g++ bug?
Date: Mon, 27 Feb 2006 12:12:46 +0100
User-agent: KNode/0.10.1

Hello,

eoolsson@gmail.com wrote:

> The following program outputs "FAIL" when compiled with g++, but
> "PASS" when compiled with gcc (on IA32):
> 
> #include <stdio.h>
> 
> int main(void) {
> short a = 0x1a10;
> short b = 0xb34e;
> 
> if((unsigned int)a >= (unsigned int)b)
> printf("FAIL\n");
> else printf("PASS\n");
> 
> return 0;
> }
> 
> When using g++, the variable "b" seems to be treated as a negative
> number even though it is cast to unsigned int. Is this a bug? Any
> ideas?
> 
> Versions:
> g++ (GCC) 3.2.3 20030502
> gcc (GCC) 3.2.3 20030502

This is an ancient gcc release. The problem seems to be fixed in gcc
3.4.4 and later, always PASS. There is no active development in the 3.2
series and almost none in the 3.3 series, so I doubt it will be fixed
for 3.2.

The following extra cast produces pass with g++ 3.3.5:

        if((unsigned int)a >= (unsigned int)((unsigned short)b))
                printf("FAIL\n");
        else printf("PASS\n");


Bernd Strieder



reply via email to

[Prev in Thread] Current Thread [Next in Thread]