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); }
-Wunreachable-code is broken and has been removed from GCC 4.5. Do not use it.