Bug 187469

Summary: Miscompile on i386 with 64-bit numbers, -Os
Product: [Fedora] Fedora Reporter: Scott Lamb <redhat>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-04-03 12:49:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
demonstration none

Description Scott Lamb 2006-03-31 07:01:58 UTC
Created attachment 127100 [details]
demonstration

Comment 1 Scott Lamb 2006-03-31 07:01:58 UTC
In the attached program are 32-bit and 64-bit factorial functions. The 32-bit function works fine. The 
64-bit function works with no optimizations but loops forever with -Os.

$ uname -a
Linux rosalyn.slamb.org 2.6.15-1.1831_FC4 #1 Tue Feb 7 13:37:42 EST 2006 i686 athlon i386 GNU/
Linux
$ gcc --version
gcc (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8)
$ gcc miscompile-64bit-Os.c
$ ./a.out 
factorial_32(5) = 120
factorial_64(5) = 120
$ gcc -Os miscompile-64bit-Os.c
$ ./a.out 
factorial_32(5) = 120
...

For what it's worth, this same program works fine on my G4 running OS X 10.4 Tiger. gcc --version 
there returns:

powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5247)

Comment 2 Jakub Jelinek 2006-04-03 12:49:03 UTC
Works correctly with GCC 4.1.0-3 (FC5 gcc).
Tracked upstream as PR27003.