gcc over-optimizes "volatile double"
Thomas R. Truscott
trt@cs.duke.edu
Wed Aug 2 13:07:00 GMT 2000
In ss-20000724 i686-pc-linux (and since sometime this year)
a "gcc -O" keeps "volatile double" in a floating point
register, which causes the program below to abort()
because on ia32 floating point registers have more
precision than "double".
I realize that gcc has the -ffloat-store option,
but IMO volatile should imply this.
Tom Truscott
volatile double zg;
int
main (void)
{ double eps, t;
volatile double z;
eps = 1;
for (;;)
{
t = eps / 2;
z = 1 + t;
if (z == 1)
break;
eps = t;
}
zg = 1 + eps;
if (zg == 1)
abort();
exit (0);
}
More information about the Gcc-bugs
mailing list