The following program illustrates an optimization problem with signbit() of a long double NAN: #include <math.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { long double n = NAN; if (signbit(n)) { fprintf(stdout, "n is negative\n"); } else { fprintf(stdout, "n is positive\n"); } exit(0); } When compiled with gcc -D_XOPEN_SOURCE=600 -o Test1 Test1.c the resulting Test1 correctly prints "n is positive". When compiled with gcc -D_XOPEN_SOURCE=600 -O -o Test1 Test1.c or gcc -D_XOPEN_SOURCE=600 -O2 -o Test1 Test1.c the resulting Test1 incorrectly prints "n is negative". I am using gcc 3.2 on SuSE Linux/x86 7.1 (Linux kernel 2.4.0 and glibc 2.2). Release: gcc 3.2 Environment: gcc 3.2 on SuSE Linux/x86 7.1 (kernel 2.4.0 and glibc 2.2)
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed on 3.2 branch. 3.3 and mainline are not affected.
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed for 3.3.