This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]