Bug 21188 - gcc over-optimizes volatile double
gcc over-optimizes volatile double
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
Blocks: 21191
  Show dependency treegraph
Reported: 2000-11-21 11:58 EST by Plummer, Martyn
Modified: 2007-04-18 12:29 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-11-27 11:28:09 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Example C program to highlight bug (8.84 KB, text/plain)
2000-11-21 12:00 EST, Plummer, Martyn
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2000:132 normal SHIPPED_LIVE Bug fixing update of GCC 2.96 2000-12-19 00:00:00 EST

  None (edit)
Description Plummer, Martyn 2000-11-21 11:58:16 EST
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.
See also
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.
Comment 1 Plummer, Martyn 2000-11-21 12:00:06 EST
Created attachment 5622 [details]
Example C program to highlight bug
Comment 2 Jakub Jelinek 2000-11-22 07:27:45 EST
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.
Comment 3 Jakub Jelinek 2000-11-27 11:28:06 EST
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
and above.

Note You need to log in before you can comment on or make changes to this bug.