This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: optimization problem with 1.0.3
- To: egcs at egcs dot cygnus dot com
- Subject: Re: optimization problem with 1.0.3
- From: Irwin Lee <itlee at leland dot Stanford dot EDU>
- Date: Sun, 06 Dec 1998 21:13:20 -0800
- References: <Pine.LNX.4.05.9812062253490.6781-100000@coffee.psychology.mcmaster.ca>
>> concerned, f is no longer even deterministic. Isn't this a bad thing?
>> Shouldn't the code generated by gcc prevent this kind of thing from
>> happening?
>
>I don't see why. how about a diagnostic message that says
>"warning: you can never compare different floats/doubles with == or !=,
>even if you think they're the same value."
When I ran into the source of my problems originally, I was not
trying to use == or != . The example I had originally
asked about was rather confused--- I didn't really understand the
nature of the problem so I couldn't illustrate it very well. But
now look at this:
beefalo% cat fp_problem2_p.c
#include <stdio.h>
double f(double x)
{
return x/3.0;
}
int main()
{
int count;
double x = 1.0, y = 1.0;
if(f(x) < f(y)) {
printf("f(x) is less than f(y)\n");
if(f(y) < f(x)) {
printf("AND\nf(y) is less than f(x)\n");
}
}
return 0;
}
beefalo% gcc fp_problem2_p.c
beefalo% a.out
f(x) is less than f(y)
AND
f(y) is less than f(x)
Surely _this_ is bad?