Red Hat Bugzilla – Bug 21188
gcc over-optimizes volatile double
Last modified: 2007-04-18 12:29:58 EDT
gcc 2.96 ignores the volatile keyword when optimizing C code.
This bug came to light in the R language (see http://www.r-project.org and
the R-base RPM on powertools), which uses a routine called "machar" to
determine the machine characteristics at runtime. As a result of the bug,
machar reports double precision to be 2^-63 instead of the correct value
2^-52 on an i686.
A search of the gcc mailing list archives shows that this bug was found
independently by Tom Truscott and reported by him on 2 August, but
without any follow-up. See
He includes a short program which aborts when the bug is triggered.
for an obviously related bug.
The machar routine from the R language is too long to include here, but you
can grab a copy from
This includes a main() function that prints the value of the double
precision. Compare with and without optimization.
Created attachment 5622 [details]
Example C program to highlight bug
I've posted a fix for this at
and am waiting now for feedback on it. If it is accepted, it will make it
into next gcc rpms.
It was not accepted, but it will take quite some time before Richard Kenner
writes a fix he wants to see, so I'll be putting this patch into gcc-2.96-65