This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/43344] New: -Wunreachable-code incorrect warning


By adding a destructor to main class to example in the bug 21228
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21228) will produce incorrect
warning about code that "will never be executed"

# g++  -Wunreachable-code gstest.cpp
gstest.cpp: In constructor ?testString::testString()?:
gstest.cpp:24: warning: will never be executed
gstest.cpp: In constructor ?testString::testString()?:
gstest.cpp:24: warning: will never be executed

#cat gstest.cpp
// #include <stdio.h>

class testStringBase
{
public:
  ~testStringBase();
  char *stringPtr;
};

testStringBase::~testStringBase()
{
  stringPtr = 0;
}

class testString : public testStringBase
{
public:
  testString();
};

testString::testString()
{
  stringPtr = (char *) 9;
}

int main(int argc, char **argv) {
  testString s;
  //  printf("s.stringPtr is %ld\n", (unsigned long) s.stringPtr);
}


-- 
           Summary: -Wunreachable-code incorrect warning
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jiri dot engelthaler at zat dot cz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43344


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]