Bug 74423 - gcc-gcc -O2 bug
gcc-gcc -O2 bug
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
alpha Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-09-23 22:25 EDT by George France
Modified: 2007-04-18 12:46 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-01 13:34:21 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
sample program that shows this problem. (912 bytes, text/plain)
2002-09-24 15:39 EDT, George France
no flags Details

  None (edit)
Description George France 2002-09-23 22:25:00 EDT
Description of Problem:

gcc -O2 produces incorrect biniaries.

Version-Release number of selected component (if applicable):

   gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-87)

How Reproducible:

   Each and every time.

Steps to Reproduce:
1. Put the following program in a file, maybe called bug.c, as follows:
#include <stdio.h>
#define           round(a)        (int)(((a)<0.0)?(a)-.5:(a)+.5)
int   zoomxoff;
SHZOOMX(int x)
  x = round(0.7*((x)-zoomxoff));
  return (short) x;
int main() {
  zoomxoff = 0;
  printf ("SHZOOMX(%d) = %hd (should be 70)\n", 100, SHZOOMX(100));
  printf ("SHZOOMX(%d) = %hd (should be -70)\n", -100, SHZOOMX(-100));
  return 0;
2.  Compile the program with:

    gcc -O2 -o bug bug.c    

3.  Execute the program with:


Actual Results:

   SHZOOMX(100) = 0 (should be 70)
   SHZOOMX(-100) = -70 (should be

Expected Results:

   SHZOOMX(100) = 70 (should be 70)
   SHZOOMX(-100) = -70 (should be

Additional Information:
This problem goes away if you compile with 'gcc -O2 -fno-sched-interblock'.  The
bug also occurs thru gcc-3.0.4 released Feb 20, 2002, but goes away in
gcc-3.1-prerelease dated April 01, 2002.

Please let me know if I can be of further assitance.

Best Regards,

Comment 1 George France 2002-09-24 15:39:55 EDT
Created attachment 77066 [details]
sample program that shows this problem.
Comment 2 George France 2002-09-24 15:41:13 EDT
I have attached another variation of the same type of code that fails in
different optimization passes.

Best Regards,

Comment 3 Mike A. Harris 2002-09-27 11:31:21 EDT
After our chat in IRC... I believe you've resolved this now.  Could you
attach the patch here, so we can ensure it gets into future erratum
Comment 4 Vladimir Makarov 2004-10-01 13:34:21 EDT
gcc-2.96 is too old now.  Its release cycle was finished long ago. 
Also I've checked the current state of gcc-3_0-branch.  The bug was
gone.  So I am closing the bug.  If it is still important to fix the
bug in gcc-2.96, the customer could reopen the case.

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