I had a macro (which converted a character into a hex value) which threw a string exception when the character was not in one of the ranges I wanted. Anyway, I receive the following ICE when I try to compile my code bug.cc: In function `short unsigned int string2Hex (const char *)': bug.cc:14: Internal compiler error. bug.cc:14: Please submit a full bug report. bug.cc:14: See <URL:http://www.gnu.org/software/gcc/bugs.html> for bug.cc:14: instructions. if the throw is replaced with a function call - no problem (apart from inelegance) if p_source[i] is replaced by a character literal - no problem it's only when I have both the throw and p_source[i] in the same statement that I get the ICE. I didn't bother with bzip2 or uuencode b/c it's so small; hope this is ok. BTW content of throwbug.s was .file "throwbug.cc" gcc2_compiled.: .global __throw Release: 2.96/2000501 Environment: [Segmentation faults on x86 Linux] System: SunOS janus 5.5.1 Generic_103640-31 sun4u sparc SUNW,Ultra-Enterprise Architecture: sun4 host: sparc-sun-solaris2.5.1 build: sparc-sun-solaris2.5.1 target: sparc-sun-solaris2.5.1 How-To-Repeat: copy the code between the -----8<-------- lines into a file throwbug.cc command: g++ throwbug.cc No options required note: the same behaviour occurred with the 20000501 snapshot -------------------------------------8<------------------------------------- # 1 "throwbug.cc" # 0 "bug.cc" unsigned short string2Hex(const char* p_source) { unsigned short myChar = 0; for (int i = 0; i < 4 && p_source[i]; ++i) { myChar <<= 4; myChar += (((p_source[i]) >= 'a' && (p_source[i]) <= 'f') ? (p_source[i] ) - ('a' - 10) : throw 1); } return myChar; } int safeMain(int argc, const char **argv) { return 0; } int main(int argc, const char** argv) { try { return safeMain(argc, argv); } catch(...) { return 1; } } ------------------------------------8<-------------------------------------- The following is the output from g++ -v --save-temps throwbug.cc Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.96/specs gcc version 2.96 20000221 (experimental) /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.96/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) throwbug.cc throwbug.ii GNU CPP version 2.96 20000221 (experimental) (cpplib) (sparc) #include "..." search starts here: #include <...> search starts here: /usr/local/include/g++-3 /usr/local/include /usr/local/sparc-sun-solaris2.5.1/include /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.96/include /usr/include End of search list. /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.96/cc1plus throwbug.ii -quiet -dumpbase throwbug.cc -version -o throwbug.s GNU C++ version 2.96 20000221 (experimental) (sparc-sun-solaris2.5.1) compiled by GNU C version 2.95.2 19991024 (release). bug.cc: In function `short unsigned int string2Hex (const char *)': bug.cc:14: Internal compiler error. bug.cc:14: Please submit a full bug report. bug.cc:14: See <URL:http://www.gnu.org/software/gcc/bugs.html> for bug.cc:14: instructions.
Fix: If I replace the throw with a function call which in turn throws an exception, g++ doesn't complain. e.g. int throwError(char p_char) { // Need to flesh out my error message with the param, but this gives idea throw "Error occurred for code p_char"; } and replace ? expression : throw 1 with ? expression : throwError(p_source[i])
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed as a bug in 20000624
From: loewis@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, msf@cs.rmit.edu.au, nobody@gcc.gnu.org Cc: Subject: Re: c++/218 Date: 25 Jun 2000 21:43:26 -0000 Synopsis: array access & throw in same statement: Internal compiler error State-Changed-From-To: open->analyzed State-Changed-By: loewis State-Changed-When: Sun Jun 25 14:43:26 2000 State-Changed-Why: Confirmed as a bug in 20000624 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=218&database=gcc
State-Changed-From-To: analyzed->closed State-Changed-Why: Appears fixed in 3.0 branch.
From: neil@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, msf@cs.rmit.edu.au, nobody@gcc.gnu.org Cc: Subject: Re: c++/218 Date: 7 May 2001 10:15:11 -0000 Synopsis: array access & throw in same statement: Internal compiler error State-Changed-From-To: analyzed->closed State-Changed-By: neil State-Changed-When: Mon May 7 03:15:10 2001 State-Changed-Why: Appears fixed in 3.0 branch. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=218&database=gcc