Bug 169654 - gcc -O1 incorrect code for unsigned long long compare
gcc -O1 incorrect code for unsigned long long compare
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc (Show other bugs)
x86_64 Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
Blocks: 161600 168424
  Show dependency treegraph
Reported: 2005-09-30 13:38 EDT by Jim Houston
Modified: 2007-11-30 17:07 EST (History)
1 user (show)

See Also:
Fixed In Version: RHBA-2006-0147
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-03-15 10:29:33 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
gcc32-pr12799.patch (2.84 KB, patch)
2005-10-02 16:01 EDT, Jakub Jelinek
no flags Details | Diff

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

  None (edit)
Description Jim Houston 2005-09-30 13:38:09 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3

Description of problem:
The following program fails when compiled with a -O1 option.
It works correctly with -O2.

$ cat aaa.c
#include <stdio.h>

unsigned int z(unsigned long long a)
        if (a >= 0xffffffffULL)
                return 0xffffffff;
        return a;

int main(int argc, char **argv)
        printf("z(0ULL)=%x\n", z(0ULL));
        return  z(0ULL);
$ gcc -O1 aaa.c -o aaa
$ ./aaa
$ gcc -O2 aaa.c -o aaa
$ ./aaa
$  gcc -v
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-49)

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

How reproducible:

Steps to Reproduce:
1.gcc -O1 aaa.c -o aaa

Actual Results:  z(0ULL)=ffffffff

Expected Results:  z(0ULL)=0

Additional info:

I checked the current gcc version 4.1.0 it doesn't have this problem.

I ran into this compiling a kernel patched with the KGDB stub which 
added a -O1 option.  In particular the function ata_scsiop_read_cap() in drivers/scsi/libata-scsi.c is incorrectly compiled if a -O1 option is
Comment 1 Jakub Jelinek 2005-10-02 16:01:24 EDT
Created attachment 119521 [details]

Backported patch that seems to fix it.
Comment 7 Red Hat Bugzilla 2006-03-15 10:29:35 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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