Bug 5230 - Spurious warning compiling duffs device with optimization
Summary: Spurious warning compiling duffs device with optimization
Status: RESOLVED DUPLICATE of bug 3846
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: ---
Assignee: Richard Henderson
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2001-12-31 10:16 UTC by Jason Thorpe
Modified: 2003-06-12 00:15 UTC (History)
5 users (show)

See Also:
Host: i386-unknown-netbsdelf
Target: i386-unknown-netbsdelf
Build: i386-unknown-netbsdelf
Known to work:
Known to fail:
Last reconfirmed:


Attachments
foo.c.gz (245 bytes, application/x-gzip )
2003-05-21 15:17 UTC, Jason Thorpe
Details
foo.c.gz (245 bytes, application/x-gzip )
2003-05-21 15:17 UTC, Jason Thorpe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Thorpe 2001-12-31 10:16:01 UTC
	GCC produces a spurious warning when compiling a duffs device
	with optimization:

dr-evil:thorpej 41$ i386-unknown-netbsdelf-gcc -S -O1 foo.c 
foo.c: In function `cksum':
foo.c:13: warning: unreachable code at beginning of switch statement
dr-evil:thorpej 42$ 

	The resulting assembly code appears correct, and produces the
	expected result when given a test input.  The warning does not
	appear if no optimization is used.

Release:
3.1 20011230 (experimental)

Environment:
System: NetBSD dr-evil 1.5Z NetBSD 1.5Z (DR-EVIL) #252: Sun Dec 9 17:39:53 PST 2001 thorpej@dr-evil:/u1/netbsd/src/sys/arch/i386/compile/DR-EVIL i386


	
host: i386-unknown-netbsdelf
build: i386-unknown-netbsdelf
target: i386-unknown-netbsdelf
configured with: ../../gcc/configure --disable-shared --prefix=/usr/local/gnu --host=i386-unknown-netbsdelf --target=i386-unknown-netbsdelf : (reconfigured)  : (reconfigured)

How-To-Repeat:
	The following C program will produce the warning when compiled
	with -O1.  It will not produce a warning when compiled with
	-O0.  In both cases, the generated assembly code is correct,
	and correct results are produced by the test inputs.

See attachments for foo.c.gz
Comment 1 Jason Thorpe 2001-12-31 10:16:01 UTC
Fix:
	The warning can be avoided by not using optimization.
Comment 2 Richard Henderson 2002-04-03 01:50:07 UTC
*** This bug has been marked as a duplicate of 3846 ***
Comment 3 Jason Thorpe 2002-11-07 09:30:54 UTC
State-Changed-From-To: closed->open
State-Changed-Why: Not actually a duplicate.
Comment 4 Wolfgang Bangerth 2002-12-06 15:49:32 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Still happens.
Comment 5 Jason Thorpe 2002-12-06 15:56:17 UTC
From: Jason R Thorpe <thorpej@wasabisystems.com>
To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: optimization/5230: Spurious warning compiling duffs device with optimization
Date: Fri, 6 Dec 2002 15:56:17 -0800

 On Fri, Dec 06, 2002 at 11:49:33PM -0000, bangerth@dealii.org wrote:
 
  > Synopsis: Spurious warning compiling duffs device with optimization
  > 
  > State-Changed-From-To: open->analyzed
  > State-Changed-By: bangerth
  > State-Changed-When: Fri Dec  6 15:49:32 2002
  > State-Changed-Why:
  >     Confirmed. Still happens.
  > 
  > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5230
  > 
 
 BTW, a test case for this has actually been checked into the GCC testsuite
 already ("duff-2").
 
 -- 
         -- Jason R. Thorpe <thorpej@wasabisystems.com>
Comment 6 Wolfgang Bangerth 2002-12-06 17:49:08 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: optimization/5230: Spurious warning compiling duffs device with
 optimization
Date: Fri, 6 Dec 2002 17:49:08 -0600 (CST)

 Just for reference, I think this is actually a duplicate of PR 8828.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth