From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4873 invoked by alias); 8 Nov 2002 11:16:02 -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 4847 invoked by uid 71); 8 Nov 2002 11:16:01 -0000 Resent-Date: 8 Nov 2002 11:16:01 -0000 Resent-Message-ID: <20021108111601.4845.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, rveldema@cs.vu.nl Resent-Reply-To: gcc-gnats@gcc.gnu.org, reichelt@igpm.rwth-aachen.de Received: (qmail 4160 invoked by uid 61); 8 Nov 2002 11:11:51 -0000 Message-Id: <20021108111151.4159.qmail@sources.redhat.com> Date: Fri, 08 Nov 2002 03:16:00 -0000 From: reichelt@igpm.rwth-aachen.de Reply-To: reichelt@igpm.rwth-aachen.de To: gcc-gnats@gcc.gnu.org Cc: rveldema@cs.vu.nl X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: rveldema@cs.vu.nl Subject: middle-end/8502: wrong code generated for switch statement X-SW-Source: 2002-11/txt/msg00405.txt.bz2 List-Id: >Number: 8502 >Category: middle-end >Synopsis: wrong code generated for switch statement >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri Nov 08 03:16:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Volker Reichelt >Release: gcc 3.1, gcc 3.2, 3.2-branch >Organization: >Environment: i686-pc-linux-gnu >Description: Consider the following testcase: --------------------------snip here------------------------- bool foo (int i) { switch (i) { case 0: return false; case 1: return false; case 2: return false; case 3: return false; case 4: return false; } return false; } int main() { return 0; } --------------------------snip here------------------------- Compiling this with gcc 3.1, 3.2 or the 3.2-branch on i686-pc-linux-gnu I get the following error message: /tmp/ccii3YKY.o: In function `foo(int)': /tmp/ccii3YKY.o(.text+0x11): undefined reference to `.L8' collect2: ld returned 1 exit status The assembler code for the function "foo" is: .align 2 .globl _Z3fooi .type _Z3fooi,@function _Z3fooi: .LFB1: pushl %ebp .LCFI0: movl %esp, %ebp .LCFI1: cmpl $4, 8(%ebp) ja .L1 movl 8(%ebp), %eax sall $2, %eax movl .L8(%eax), %eax <--------- !!!!! .L1: movl $0, %eax popl %ebp ret .LFE1: .Lfe1: .size _Z3fooi,.Lfe1-_Z3fooi Note that the problem disappears with only four cases in the switch statement. The problem doesn't arise on the main trunk, though. Because this is a regression from 3.0.x, I rate the PR as "high priority". BTW, the PR is actually a distilled version of PR 6679 of R.S. Veldema, which is quite large and and slightly corrupted. Therefore, I closed PR 6679 and created this one. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: