Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 227293 - gcc -O2 generates invalid code
gcc -O2 generates invalid code
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2007-02-04 16:27 EST by Dmitry V. Levin
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: 2007-02-05 08:22:43 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
obj_reloc.c (339 bytes, text/plain)
2007-02-04 16:27 EST, Dmitry V. Levin
no flags Details
obj_reloc2.c (645 bytes, text/plain)
2007-02-05 08:09 EST, Dmitry V. Levin
no flags Details

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

  None (edit)
Description Dmitry V. Levin 2007-02-04 16:27:54 EST
The attached code (reduced version of modutils-2.4.27/obj/obj_reloc.c)
is miscompiled by gcc-4.1.1-51.fc6:

the "head = 0" initialization is lost, therefore the code uses uninitialized stack variable.

Steps to Reproduce:
$ gcc -S -O2 -Wall -W -fverbose-asm obj_reloc.c
$ fgrep head obj_reloc.s 
        movl    -8(%ebp), %eax  # head, temp.31
$ gcc -S -O1 -Wall -W -fverbose-asm obj_reloc.c
$ fgrep head obj_reloc.s 
        movl    $0, -8(%ebp)    #, head
        movl    -8(%ebp), %eax  # head, temp.29
Comment 1 Dmitry V. Levin 2007-02-04 16:27:54 EST
Created attachment 147331 [details]
Comment 2 Jakub Jelinek 2007-02-05 07:22:14 EST
This is reduced too much for a useful testcase.  There is nothing that actually
ever looks at the created chain, so the compiler might as well optimize it all
out completely.  I have tried to add something which would use the chain, but
at that point gcc always initializes head.
Comment 3 Dmitry V. Levin 2007-02-05 08:09:17 EST
Created attachment 147353 [details]

Test case from original bug report.
Comment 4 Jakub Jelinek 2007-02-05 08:22:43 EST
Just curious why are you filling the bug here instead of upstream?  You are using
altlinux gcc, not FC and the bug is very well reproduceable also with vanilla
upstream gcc-4_1-branch.

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