Bug 227293 - gcc -O2 generates invalid code
Summary: gcc -O2 generates invalid code
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 6
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL: https://bugzilla.altlinux.org/show_bu...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-02-04 21:27 UTC by Dmitry V. Levin
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-02-05 13:22:43 UTC
Type: ---
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 30708 0 None None None Never

Description Dmitry V. Levin 2007-02-04 21:27:54 UTC
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 21:27:54 UTC
Created attachment 147331 [details]
obj_reloc.c

Comment 2 Jakub Jelinek 2007-02-05 12:22:14 UTC
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 13:09:17 UTC
Created attachment 147353 [details]
obj_reloc2.c

Test case from original bug report.

Comment 4 Jakub Jelinek 2007-02-05 13:22:43 UTC
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.