Bug 83402

Summary: Creates bogus warnings with '-Wunreachable-code'
Product: [Retired] Red Hat Raw Hide Reporter: Enrico Scholz <rh-bugzilla>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-03 12:02:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Enrico Scholz 2003-02-03 22:59:24 UTC
Description of problem:

-----
$ cat foo.cc
#include <cassert>

struct A
{
    bool	f();
    void	g();

    void	*x;
};

bool
A::f()
{
  return x!=0;
}

void
A::g()
{
  assert(f());
  
  extern volatile int y;
  y = 0;
}

$  g++ -O3 -Wunreachable-code -c foo.cc
foo.cc: In member function `void A::g()':
foo.cc:22: warning: will never be executed

-----

This warning is wrong; it happens also when using 'assert(f() || !f())' but not,
with 'assert(true)' or 'assert(false)' where it would be right.


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

gcc-c++-3.2.1-5

Comment 1 Richard Henderson 2004-10-03 12:02:44 UTC
Fixed with gcc 3.2.3-20.