g++ (actually cc1plus process) reports segmentation fault and internal compiler error when building "dar" package with -O2 optimization on alpha-linux. tst.ii is the preprocessed source of simplified source file which triggers problem (.cpp is ~80 lines long, most of .ii file lines are STL headers; original classes structure was much more complicated). This file compiles correctly using gcc 3.3.2 with -O2 on i*86 (with -march=i386/i586/i686/athlon), sparc and ppc machines. On alpha gcc 2.95.3 works too with -O2 optimization. When running g++ on alpha I get: $ g++ -O2 -c tst.ii tst.cpp: In constructor `inode::inode()': tst.cpp:87: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. I tried to run cc1plus under gdb and got: [...] [with _Tp = char] inode::inode() Program received signal SIGSEGV, Segmentation fault. insert_insn_on_edge (pattern=0x20001c0d340, e=0x0) at ../../gcc/cfgrtl.c:1345 1345 if ((e->flags & EDGE_ABNORMAL) && EDGE_CRITICAL_P (e)) (gdb) bt #0 insert_insn_on_edge (pattern=0x20001c0d340, e=0x0) at ../../gcc/cfgrtl.c:1345 #1 0x000000012025251c in fixup_abnormal_edges () at ../../gcc/reload1.c:9524 #2 0x000000012023f840 in reload (first=0x200015b87e8, global=1) at ../../gcc/reload1.c:1287 #3 0x00000001202eeabc in global_alloc (file=0x0) at ../../gcc/global.c:583 #4 0x000000012027b77c in rest_of_compilation (decl=0x200013a5008) at ../../gcc/toplev.c:3305 #5 0x00000001200a6720 in genrtl_finish_function (fn=0x200013a5008) at ../../gcc/cp/semantics.c:2589 #6 0x00000001200a627c in expand_body (fn=0x200013a5008) at ../../gcc/cp/semantics.c:2412 #7 0x00000001200adc40 in maybe_clone_body (fn=0x200013955f0) at ../../gcc/cp/optimize.c:274 #8 0x00000001200a6038 in expand_body (fn=0x200013955f0) at ../../gcc/cp/semantics.c:2328 #9 0x000000012006d310 in yyparse () at parse.y:815 #10 0x00000001200cc094 in c_common_parse_file (set_yydebug=29414208) at ../../gcc/c-lex.c:159 #11 0x0000000120279638 in compile_file () at ../../gcc/toplev.c:2130 #12 0x0000000120280ee4 in do_compile () at ../../gcc/toplev.c:5402 #13 0x0000000120280fc4 in toplev_main (argc=5, argv=0x11ffffc38) at ../../gcc/toplev.c:5432 #14 0x00000001200d5188 in main (argc=29414208, argv=0x0) at ../../gcc/main.c:35 insert_insn_on_edge() is called with e=NULL, but the function doesn't expect this. In fixup_abnormal_edges() before the call bb->succ is not NULL, bb->succ->flags == 14, bb->succ->succ_next == NULL. Environment: System: Linux alpha 2.4.22 #5 Fri Oct 3 11:20:04 CEST 2003 alpha EV6 unknown PLD Linux Architecture: alpha host: alpha-pld-linux-gnu build: alpha-pld-linux-gnu target: alpha-pld-linux-gnu configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++,f77,objc,ada,java,ksi --enable-c99 --enable-long-long --enable-multilib --enable-nls --with-gnu-as --with-gnu-ld --with-system-zlib --with-slibdir=/lib --without-x alpha-pld-linux How-To-Repeat: Compile attached preprocessed file (tst.ii) with one of: -O2 (adding just -fno-inline-functions doesn't help) -O3
Fix: Workaround is to compile with one of: -O1 -O2 -fno-inline -O2 -fno-default-inline
Created attachment 5101 [details] Preprocessed source that triggers SEGV+ICE on alpha-linux
Confirmed with 3.3.2. Not present on mainline.
Created attachment 5102 [details] Reduced test case (77 lines)
Investigating.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00630.html>.
Subject: Bug 12965 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2003-12-07 13:05:43 Modified files: gcc : ChangeLog caller-save.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/opt: noreturn-1.C Log message: PR optimization/12965 * caller-save.c (save_call_clobbered_regs): Do not save/restore registers around no-return calls. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1946&r2=2.1947 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/caller-save.c.diff?cvsroot=gcc&r1=1.56&r2=1.57 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3237&r2=1.3238 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/noreturn-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
I can confirm: gcc 3.3.2 with this patch is able to compile "dar" with -O2 on alpha-linux. Thanks.
Subject: Bug 12965 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: ebotcazou@gcc.gnu.org 2003-12-11 07:48:07 Modified files: gcc : ChangeLog caller-save.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/opt: noreturn-1.C Log message: Backport from mainline: 2003-12-07 Eric Botcazou <ebotcazou@libertysurf.fr> PR optimization/12965 * caller-save.c (save_call_clobbered_regs): Do not save/restore registers around no-return calls. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.836&r2=1.16114.2.837 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/caller-save.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.53&r2=1.53.20.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.328&r2=1.2261.2.329 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/noreturn-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Thanks for the confirmation.