Mail Archives: cygwin/2009/11/17/04:24:14
Hello fellow cygwinners,
I'm seeing incorrect behavior when I use the "-ffast-math" option to gcc on=
cygwin. Here is a Short Test Case:
#include <stdio.h>
#include <math.h>
int main(void)
{
double d1 =3D 0.0;
double d2 =3D 0.0;
d1 =3D tan(d1);
d2 =3D tan(d2);
(void) printf("d1 =3D %lg, expecting 0 (or -0)\n", d1);
(void) printf("d2 =3D %lg, expecting 0 (or -0)\n", d2);
return 0;
}
Compile this with "gcc -ffast-math testprog.c -o testprog", then run "./tes=
tprog". Correct output would be:
d1 =3D 0, expecting 0 (or -0)
d2 =3D 0, expecting 0 (or -0)
Some time ago, on cygwin 1.5 and presumably with an older version of gcc, t=
his code (well, actually, a more complicated version of this in a library w=
e use) worked correctly. It worked correctly both with and without "-mno-c=
ygwin", and both with and without -ffast-math.
Today, on cygwin 1.7, I get this output:
d1 =3D -0, expecting 0 (or -0)
d2 =3D nan, expecting 0 (or -0)
I get this output from both gcc-3 (which is 3.4.4) and from gcc-4 (which is=
4.3.4), when -ffast-math is used. If I remove -ffast-math, I get the expe=
cted output of 0 for both d1 and d2. If I compile with -mno-cygwin on gcc-=
3, either with or without -ffast-math, I get the expected output of 0 for b=
oth d1 and d2. So the problem seems to be limited to -ffast-math, and to t=
he cygwin (non-mingw32) platform, and perhaps to relatively recent versions=
of gcc.
My completely uninformed guess is that this is a cygwin-specific defect in =
gcc. But I really don't know.
Any ideas how I should deal with this would be helpful!
--=20
Eric
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -