https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89726

--- Comment #3 from Xan Lopez <xan at igalia dot com> ---
FWIW, the previous testcase I was using, which is a bit more convoluted, is
this one:

#include <math.h>
#include <stdio.h>

double mathCeil(double n)
{
    return ceil(n);
}

int main()
{
    double a = -0.9;
    double result = mathCeil(a);

    if (signbit(result))
        printf("CORRECT: result is %f\n", result);
    else
        printf("ERROR: result is %f (should be -0)\n", result);

    return 0;
}

Testing, compiling with SSE2 instead of x87, gives:

niraikanai:~/js/32bit%/home/xan/gccbuild/bin/gcc -march=pentium4 -msse2
-mfpmath=sse -m32 -O2 -fPIC -o ceil ceil.c -lm
niraikanai:~/js/32bit%./ceil                                                    
ERROR: result is 0.000000 (should be -0)
niraikanai:~/js/32bit%/home/xan/gccbuild/bin/gcc -march=pentium4 -msse2
-mfpmath=sse -m32 -O2 -o ceil ceil.c -lm      
niraikanai:~/js/32bit%./ceil                                                    
CORRECT: result is -0.000000
niraikanai:~/js/32bit%

Apparently in this case what makes the error show up is passing the -fPIC flag.

Reply via email to