Bug 74423 - gcc-gcc -O2 bug
Summary: gcc-gcc -O2 bug
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: alpha
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-09-24 02:25 UTC by George France
Modified: 2007-04-18 16:46 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-01 17:34:21 UTC
Embargoed:


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

Description George France 2002-09-24 02:25:00 UTC
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;
 
short
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:

    ./bug

Actual Results:

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

Expected Results:

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


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,


--George

Comment 1 George France 2002-09-24 19:39:55 UTC
Created attachment 77066 [details]
sample program that shows this problem.

Comment 2 George France 2002-09-24 19:41:13 UTC
I have attached another variation of the same type of code that fails in
different optimization passes.

Best Regards,


--George

Comment 3 Mike A. Harris 2002-09-27 15:31:21 UTC
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
also?


Comment 4 Vladimir Makarov 2004-10-01 17:34:21 UTC
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.