Package: g++ Version: 3.2.2-0 Severity: important The attached source file causes g++ to report an internal compiler error:
% g++ -c g++bug.cc g++bug.cc: In function `int main(int, char**)': g++bug.cc:29: jump to case label g++bug.cc:26: crosses initialization of `someclass obj1' g++bug.cc:33: jump to case label g++bug.cc:30: crosses initialization of `someotherclass obj2' g++bug.cc:26: crosses initialization of `someclass obj1' Internal compiler error: Error reporting routines re-entered. Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. I'm not sure what is the cause of this; it seems to be something to do with the switch statement and the fact that someclass and someotherclass have destructors. (Commenting out the destructors in those classes makes the internal compiler error go away, somehow.) Also, why doesn't g++ like the declaration of objects inside a switch statement? Is this invalid according to the C++ spec, or is it a GCC oddity? Regardless, the internal compiler error is certainly a bug. I've also attached the preprocessed file (g++bug.ii) generated by g++ -v -save-temps. The output from g++ is also attached. Here are the relevant packages on my system (libstdc++2.10* is probably not relevant, but *just* in case it has something to do with it, I include it here): ii g++ 3.2.2-0 The GNU C++ compiler. ii libstdc++2.10 2.95.2-13 The GNU stdc++ library ii libstdc++2.10-dev 2.95.4-15 The GNU stdc++ library (development files) ii libstdc++2.10-glibc2.2 2.95.4-15 The GNU stdc++ library ii libstdc++5 3.2.3-0pre1 The GNU Standard C++ Library v3 ii libstdc++5-dev 3.2.3-0pre1 The GNU Standard C++ Library v3 (development files) I'm running a custom-built kernel (2.4.19) on i686, just in case that matters (probably not). T -- To err is human; to forgive is not our policy. -- Samuel Adler
/* * g++ 3.2 bug in handling switch statements that contain object declarations * constructed using objects declared outside the switch. */ class common { }; class someclass { public: someclass(common *c) { } ~someclass() { } }; class someotherclass { public: someotherclass(common *c) { } ~someotherclass() { } }; int main(int argc, char *argv[]) { enum { CHOICE_A, CHOICE_B } choice = CHOICE_A; common commonobj; switch (choice) { case CHOICE_A: someclass obj1(&commonobj); // do something break; case CHOICE_B: someotherclass obj2(&commonobj); // do something break; default: break; } }
# 1 "g++bug.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "g++bug.cc" class common { }; class someclass { public: someclass(common *c) { } ~someclass() { } }; class someotherclass { public: someotherclass(common *c) { } ~someotherclass() { } }; int main(int argc, char *argv[]) { enum { CHOICE_A, CHOICE_B } choice = CHOICE_A; common commonobj; switch (choice) { case CHOICE_A: someclass obj1(&commonobj); break; case CHOICE_B: someotherclass obj2(&commonobj); break; default: break; } }
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.3/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux Thread model: posix gcc version 3.2.3 20030210 (Debian prerelease) /usr/lib/gcc-lib/i386-linux/3.2.3/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ g++bug.cc g++bug.ii GNU CPP version 3.2.3 20030210 (Debian prerelease) (cpplib) (i386 Linux/ELF) ignoring nonexistent directory "/usr/i386-linux/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/3.2 /usr/include/c++/3.2/i386-linux /usr/include/c++/3.2/backward /usr/local/include /usr/lib/gcc-lib/i386-linux/3.2.3/include /usr/include End of search list. /usr/lib/gcc-lib/i386-linux/3.2.3/cc1plus -fpreprocessed g++bug.ii -quiet -dumpbase g++bug.cc -version -o g++bug.s GNU CPP version 3.2.3 20030210 (Debian prerelease) (cpplib) (i386 Linux/ELF) GNU C++ version 3.2.3 20030210 (Debian prerelease) (i386-linux) compiled by GNU C version 3.2.3 20030210 (Debian prerelease). g++bug.cc: In function `int main(int, char**)': g++bug.cc:29: jump to case label g++bug.cc:26: crosses initialization of `someclass obj1' g++bug.cc:33: jump to case label g++bug.cc:30: crosses initialization of `someotherclass obj2' g++bug.cc:26: crosses initialization of `someclass obj1' Internal compiler error: Error reporting routines re-entered. Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.