option -ffloat-store has no effect
Petr Savicky
savicky@cs.cas.cz
Sat Dec 3 00:35:00 GMT 2005
Dear gcc-help,
the option -ffloat-store has no effect on the following program.
If the program
#include <stdio.h>
double a,i,x;
int main(int argc, char *argv[])
{
a = 1;
for (i=1; i<100; i++) {
x = i*(a/i);
if (x != (i*(a/i))) printf("%f\n",i);
}
}
is compiled with gcc -O0 -ffloat-store
or with gcc -O0 -fno-float-store,
then the obtained binary executable program is the same (verified by diff)
and produces the output
41.000000
45.000000
55.000000
61.000000
82.000000
90.000000
99.000000
So, there are two questions:
1. Why -ffloat-store has no effect?
2. Is there some other option needed to guarantee that after
double a,i,x;
...
x = i*(a/i);
the test
(x == i*(a/i))
is satisfied?
I use Fedora Core release 2 on Xeon processor.
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
Thank you in advance for any help.
Petr
More information about the Gcc-help
mailing list