I have a small C++ code segment that produces an invalid warning about unreachable code. It might be similar to #19354 but that bug is reported fixed in 4.0.0, and indeed the example there works in my build. homerun[/home/etalvola]<184> g++ -v -save-temps -m64 -mcpu=v9 -O0 -Wunreachable- code gstest.cpp Using built-in specs. Target: sparc-sun-solaris2.8 Configured with: ../configure --prefix=/usr/local/geneva/packages/gcc Thread model: posix gcc version 4.0.0 /usr/local-sol/geneva/packages/gcc/bin/../libexec/gcc/sparc-sun- solaris2.8/4.0.0/cc1plus -E -quiet -v -iprefix /usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun-solaris2.8/4.0.0/ - D__arch64__ -D__sparcv9 gstest.cpp -mptr64 -mstack-bias -mno-v8plus -m64 - mcpu=v9 -Wunreachable-code -O0 -fpch-preprocess -o gstest.ii ignoring nonexistent directory "/usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../../sparc-sun-solaris2.8/include" ignoring duplicate directory "/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../../include/c++/4.0.0" ignoring duplicate directory "/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../../include/c++/4.0.0/sparc-sun-solaris2.8" ignoring duplicate directory "/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../../include/c++/4.0.0/backward" ignoring duplicate directory "/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun- solaris2.8/4.0.0/include" ignoring nonexistent directory "/usr/local/geneva/packages/gcc/lib/gcc/sparc- sun-solaris2.8/4.0.0/../../../../sparc-sun-solaris2.8/include" #include "..." search starts here: #include <...> search starts here: /usr/local-sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../../include/c++/4.0.0 /usr/local-sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../../include/c++/4.0.0/sparc-sun-solaris2.8 /usr/local-sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../../include/c++/4.0.0/backward /usr/local-sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/include /usr/local/include /usr/local/geneva/packages/gcc/include /usr/include End of search list. /usr/local-sol/geneva/packages/gcc/bin/../libexec/gcc/sparc-sun- solaris2.8/4.0.0/cc1plus -fpreprocessed gstest.ii -mptr64 -mstack-bias -mno- v8plus -quiet -dumpbase gstest.cpp -m64 -mcpu=v9 -auxbase gstest -O0 - Wunreachable-code -version -o gstest.s GNU C++ version 4.0.0 (sparc-sun-solaris2.8) compiled by GNU C version 3.3.3. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 gstest.cpp: In constructor 'testStringBase::testStringBase()': gstest.cpp:15: warning: will never be executed /usr/ccs/bin/as -V -Qy -s -xarch=v9 -o gstest.o gstest.s /usr/ccs/bin/as: Sun WorkShop 6 99/08/18 /usr/local-sol/geneva/packages/gcc/bin/../libexec/gcc/sparc-sun- solaris2.8/4.0.0/collect2 -V -Y P,/usr/lib/sparcv9 -Qy /usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/sparcv9/crt1.o /usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/sparcv9/crti.o /usr/ccs/lib/sparcv9/values-Xa.o /usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/sparcv9/crtbegin.o -L/usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun-solaris2.8/4.0.0/sparcv9 - L/usr/local-sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun-solaris2.8/4.0.0 - L/usr/local-sol/geneva/packages/gcc/bin/../lib/gcc - L/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun-solaris2.8/4.0.0/sparcv9 - L/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun-solaris2.8/4.0.0 - L/usr/ccs/bin/sparcv9 -L/usr/ccs/bin -L/usr/ccs/lib/sparcv9 -L/usr/ccs/lib - L/usr/local-sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../sparcv9 -L/usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun-solaris2.8/4.0.0/../../.. - L/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun- solaris2.8/4.0.0/../../../sparcv9 - L/usr/local/geneva/packages/gcc/lib/gcc/sparc-sun-solaris2.8/4.0.0/../../.. - L/lib/sparcv9 -L/usr/lib/sparcv9 gstest.o -lstdc++ -lm -lgcc_s -lgcc -lc - lgcc_s -lgcc -lc /usr/local-sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun- solaris2.8/4.0.0/sparcv9/crtend.o /usr/local- sol/geneva/packages/gcc/bin/../lib/gcc/sparc-sun-solaris2.8/4.0.0/sparcv9/crtn.o ld: Software Generation Utilities - Solaris Link Editors: 5.8-1.273 homerun[/home/etalvola]<185> cat gstest.cpp // #include <stdio.h> class testStringBase { public: char *stringPtr; }; 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); } If the lines are uncommented - the pointer is set to '9' so clearly the code is being executed.
Let first say this is the C++ front-end producing the default constructor of testStringBase which is declared as: testStringBase()throw() {} and plus that at the wrong line (which is a different bug which I opened already).
: Search converges between 2004-05-11-trunk (#454) and 2004-05-14-trunk (#455). : Search converges between 2003-11-11-ssa (#132) and 2003-11-14-ssa (#133).
Leaving as P2; this should be fixed.
Subject: Bug 21228 Author: mmitchel Date: Tue Dec 20 08:24:10 2005 New Revision: 108849 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108849 Log: PR c++/21228 * decl.c (use_eh_spec_block): New function. (store_parm_decls): Use it. (finish_function): Likewise. PR c++/21228 * g++.dg/warn/Wunreachable-code-2.C: New test. Added: branches/gcc-4_0-branch/gcc/testsuite/g++.dg/warn/Wunreachable-code-2.C Modified: branches/gcc-4_0-branch/gcc/cp/ChangeLog branches/gcc-4_0-branch/gcc/cp/decl.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
Subject: Bug 21228 Author: mmitchel Date: Tue Dec 20 08:26:04 2005 New Revision: 108850 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108850 Log: PR c++/21228 * decl.c (use_eh_spec_block): New function. (store_parm_decls): Use it. (finish_function): Likewise. PR c++/21228 * g++.dg/warn/Wunreachable-code-2.C: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/Wunreachable-code-2.C Modified: branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/decl.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed in 4.0.3.
Subject: Bug 21228 Author: mmitchel Date: Tue Dec 20 08:48:13 2005 New Revision: 108851 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108851 Log: PR c++/21228 * decl.c (use_eh_spec_block): New function. (store_parm_decls): Use it. (finish_function): Likewise. PR c++/21228 * g++.dg/warn/Wunreachable-code-2.C: New test. Added: trunk/gcc/testsuite/g++.dg/warn/Wunreachable-code-2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog