Bug 54367 - incorrect warning from -Wunreachable-code
incorrect warning from -Wunreachable-code
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-10-04 17:44 EDT by Need Real Name
Modified: 2007-04-18 12:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-10-04 17:49:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Need Real Name 2001-10-04 17:44:54 EDT
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 17:48:59 EDT
Created attachment 33420 [details]
small test case
Comment 2 Jakub Jelinek 2001-10-18 04:54:22 EDT
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.