This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
option -ffloat-store has no effect
- From: Petr Savicky <savicky at cs dot cas dot cz>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 3 Dec 2005 01:35:24 +0100
- Subject: option -ffloat-store has no effect
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