Bug 54367 - incorrect warning from -Wunreachable-code
Summary: incorrect warning from -Wunreachable-code
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-10-04 21:44 UTC by Need Real Name
Modified: 2007-04-18 16:37 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2001-10-04 21:49:03 UTC
Embargoed:


Attachments (Terms of Use)
small test case (1.64 KB, text/c)
2001-10-04 21:48 UTC, Need Real Name
no flags Details

Description Need Real Name 2001-10-04 21:44:54 UTC
Description of Problem:

When compiling the test program with -O2 -Wunreachable-code, the
compiler says:
  thisfile.c: In function `run_timer':
  thisfile.c:35: warning: will never be executed
Which is not correct.  gcc-3.0 seems to be ok.  I hope the
optimizer isn't using the same information that the warning
is because the test program prints:
 run_timer: testing
 run_timer: compiler lied
so the return must be executed (or the code must be rearranged
so that another return is executed).


Version-Release number of selected component (if applicable):

 gcc-2.96-85
 version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)


How Reproducible:

Works everytime for me with the test program that I will
attach to the bug report.


Steps to Reproduce:
1. gcc -O2 -Wunreachable-code thisfile.c
2. ./a.out


Actual Results:

 thisfile.c: In function `run_timer':
 thisfile.c:35: warning: will never be executed  

 run_timer: testing
 run_timer: compiler lied


Expected Results:

 No warning (well, at least not that warning) from the
 compiler.  Testcase output would be the same but the
 message would no longer be correct (the compiler wouldn't
 have lied).


Additional Information:

Comment 1 Need Real Name 2001-10-04 21:48:59 UTC
Created attachment 33420 [details]
small test case

Comment 2 Jakub Jelinek 2001-10-18 08:54:22 UTC
This is a false positive warning, comment in jump.c even mentions this:
CSE and inlining can duplicate insns, so it's possible to get spurious warnings from this.
But I really don't want to touch this part of the 2.96-RH compiler at this point,
it would mean destabilizing it just for a couple of false positive warnings.


Note You need to log in before you can comment on or make changes to this bug.