Hello, [EMAIL PROTECTED] 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 _______________________________________________ Help-gplusplus mailing list Help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus