Bug 21188 - gcc over-optimizes volatile double
Summary: gcc over-optimizes volatile double
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks: 21191
TreeView+ depends on / blocked
 
Reported: 2000-11-21 16:58 UTC by Plummer, Martyn
Modified: 2007-04-18 16:29 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2000-11-27 16:28:09 UTC
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2000:132 0 normal SHIPPED_LIVE Bug fixing update of GCC 2.96 2000-12-19 05:00:00 UTC

Description Plummer, Martyn 2000-11-21 16:58:16 UTC
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
http://gcc.gnu.org/ml/gcc-bugs/2000-08/msg00037.html
He includes a short program which aborts when the bug is triggered.
See also
http://gcc.gnu.org/ml/gcc-bugs/2000-08/msg00038.html
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
http://calvin.iarc.fr/gcc/machar.c
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 17:00:06 UTC
Created attachment 5622 [details]
Example C program to highlight bug

Comment 2 Jakub Jelinek 2000-11-22 12:27:45 UTC
I've posted a fix for this at
http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01227.html
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 16:28:06 UTC
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.