This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/8632: [3.3 regression] uninitialized argument passed to leaf function w/o side-effects
- From: glen at imodulo dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 19 Nov 2002 03:18:27 -0000
- Subject: optimization/8632: [3.3 regression] uninitialized argument passed to leaf function w/o side-effects
- Reply-to: glen at imodulo dot com
>Number: 8632
>Category: optimization
>Synopsis: [3.3 regression] uninitialized argument passed to leaf function w/o side-effects
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Nov 18 19:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Glen Nakamura
>Release: gcc version 3.3 20021118 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
GCC generates the following code for function main:
main:
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
xorl %esi, %esi
pushl %ebx
subl $12, %esp
andl $-16, %esp
.p2align 4,,15
.L8:
movl %esi, 4(%esp)
movl a, %eax
movl %eax, (%esp)
call foo
testl %eax, %eax
je .L14
decl %eax
leal 1(%esi), %ebx
je .L15
.L11:
movl %ebx, %esi
jmp .L8
.p2align 4,,7
.L15:
movl %ebx, 4(%esp)
movl %edi, (%esp) <<< %edi is uninitialized
call foo
...
The problem goes away if foo calls another function,
or if foo writes to a global variable. The testcase also
works if we compile with any of the following:
gcc -O0 -mcpu=i686 testcase.c
gcc -O1 -mcpu=i686 testcase.c
gcc -O2 -mcpu=i586 testcase.c
>How-To-Repeat:
gcc -O2 -mcpu=i686 testcase.c
./a.out
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="testcase.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="testcase.c"
ZXh0ZXJuIHZvaWQgYWJvcnQgKCk7CgpzdGF0aWMgaW50IGEgPSAxMjM0NTsKCnN0YXRpYyBpbnQK
Zm9vIChpbnQgYiwgaW50IGlkeCkKewogIGlmIChiICE9IGEpCiAgICByZXR1cm4gLTE7CiAgZWxz
ZSBpZiAoaWR4IDwgMikKICAgIHJldHVybiAxOwogIGVsc2UKICAgIHJldHVybiAwOwp9CgppbnQK
bWFpbiAoKQp7CiAgaW50IGlkeCA9IDA7CgogIHdoaWxlIChmb28gKGEsIGlkeCkpCiAgICB7CiAg
ICAgIGlmIChmb28gKGEsIGlkeCkgPT0gMQoJICAmJiBmb28gKGEsIGlkeCArIDEpID09IC0xKQoJ
ewoJICBhYm9ydCAoKTsKCX0KICAgICAgKytpZHg7CiAgICB9CiAgcmV0dXJuIDA7Cn0K