Bug 54367

Summary: incorrect warning from -Wunreachable-code
Product: [Retired] Red Hat Linux Reporter: Need Real Name <rocombs>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WONTFIX QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-10-04 21:49:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
small test case none

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.