From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18692 invoked by alias); 19 Nov 2002 03:26:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 18668 invoked by uid 71); 19 Nov 2002 03:26:02 -0000 Resent-Date: 19 Nov 2002 03:26:02 -0000 Resent-Message-ID: <20021119032602.18667.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, glen@imodulo.com Received: (qmail 17685 invoked by uid 61); 19 Nov 2002 03:18:27 -0000 Message-Id: <20021119031827.17684.qmail@sources.redhat.com> Date: Mon, 25 Nov 2002 08:48:00 -0000 From: glen@imodulo.com Reply-To: glen@imodulo.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/8632: [3.3 regression] uninitialized argument passed to leaf function w/o side-effects X-SW-Source: 2002-11/txt/msg00937.txt.bz2 List-Id: >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