From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 Description of problem: Below is an example of something I hit in my code. Not a big deal, repair my bad code by putting the case with the declaration in a block. I see from the C++ standard that jumping (goto or switch) across a non-POD declaration (or any declaration with an initializer) is forbidden. Just a bit surprised to see the compiler report an internal error on it. Note that if instead of a std::string it is a POD type declared in the case statement, the warning is still there about crossing initialization but not the internal compiler error. temp(1552)$ g++ --version g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-34) temp(1551)$ cat foo.cpp #include <string> int main(void) { int i = 4; switch (i) { case 1: std::string bar="quux"; break; default: break; } return 0; } temp(1550)$ g++ -Wall -o foo foo.cpp foo.cpp: In function `int main()': foo.cpp:11: jump to case label foo.cpp:9: crosses initialization of `std::string bar' Internal compiler error: Error reporting routines re-entered. Please submit a full bug report, with preprocessed source if appropriate. Version-Release number of selected component (if applicable): gcc-3.2.3-34 How reproducible: Always Steps to Reproduce: 1. See Description above for C++ program and compiler args used 2. 3. Actual Results: I saw this: Internal compiler error: Error reporting routines re-entered. Expected Results: Error message is fine. Just surprised to see an internal compiler error. Additional info:
Can't reproduce with RHEL3 U7: g++ -v; g++ -Wall -o 183386{,.C}; echo $? Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-54) 183386.C: In function `int main()': 183386.C:9: jump to case label 183386.C:7: crosses initialization of `std::string bar' 183386.C:9: warning: destructor needed for `std::string bar' 183386.C:9: warning: where case label appears here 183386.C:9: warning: (enclose actions of previous case statements requiring destructors in their own scope.) 1