Bug 187469 - Miscompile on i386 with 64-bit numbers, -Os
Miscompile on i386 with 64-bit numbers, -Os
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2006-03-31 02:01 EST by Scott Lamb
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-04-03 08:49:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
demonstration (672 bytes, text/plain)
2006-03-31 02:01 EST, Scott Lamb
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 27003 None None None Never

  None (edit)
Description Scott Lamb 2006-03-31 02:01:58 EST
Created attachment 127100 [details]
Comment 1 Scott Lamb 2006-03-31 02:01:58 EST
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/
$ 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 08:49:03 EDT
Works correctly with GCC 4.1.0-3 (FC5 gcc).
Tracked upstream as PR27003.

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