This code crashes the C++ compiler: extern void a(void); void b(void) { l: a(); l: a(); goto l; } sample output: test.cc: In function `void b()': test.cc:6: error: duplicate label `l' test.cc:6: internal compiler error: Segmentation fault 2.95 does not crash, but 3.2, 3.3, 3.4 all do. (3.2 and 3.3 print "confused by earlier errors, bailing out" instead of the ICE message - this is normal ICE-after-error suppression.) Stack crawl: Program received signal SIGSEGV, Segmentation fault. label_rtx (label=0x0) at /home/zack/src/gcc/vanilla/gcc/stmt.c:490 490 if (TREE_CODE (label) != LABEL_DECL) (gdb) bt #0 label_rtx (label=0x0) at /home/zack/src/gcc/vanilla/gcc/stmt.c:490 #1 0x083a8207 in expand_label (label=0x0) at /home/zack/src/gcc/vanilla/gcc/stmt.c:584 During symbol reading, unsupported stack op: 'DW_OP_piece'. During symbol reading, unsupported stack op: 'DW_OP_piece'. #2 0x0816ea23 in expand_stmt (t=0x4019cf14) at /home/zack/src/gcc/vanilla/gcc/c-semantics.c:850 #3 0x0816e11d in genrtl_compound_stmt (t=0x4019ce9c) at /home/zack/src/gcc/vanilla/gcc/c-semantics.c:722 #4 0x0816e689 in expand_stmt (t=0x4019ce9c) at /home/zack/src/gcc/vanilla/gcc/c-semantics.c:828 #5 0x0816e11d in genrtl_compound_stmt (t=0x4019ce60) at /home/zack/src/gcc/vanilla/gcc/c-semantics.c:722 #6 0x0816e689 in expand_stmt (t=0x4019ce60) at /home/zack/src/gcc/vanilla/gcc/c-semantics.c:828 #7 0x0813b9c7 in expand_body (fn=0x401a972c) at /home/zack/src/gcc/vanilla/gcc/cp/semantics.c:2789 #8 0x081000ba in cp_parser_function_definition_after_declarator ( parser=0x401ab0c0, inline_p=44) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:13433 #9 0x08100032 in cp_parser_function_definition_from_specifiers_and_declarator (parser=0x401ab0c0, decl_specifiers=0x400183a0, attributes=0x400183a0, declarator=0x400183a0) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:13372 #10 0x080fada3 in cp_parser_init_declarator (parser=0x401ab0c0, decl_specifiers=0x4019cdfc, prefix_attributes=0x0, function_definition_allowed_p=true, member_p=false, function_definition_p=0xbfffdef3) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:9233 #11 0x080f7d7d in cp_parser_simple_declaration (parser=0x401ab0c0, function_definition_allowed_p=true) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:6113 #12 0x080f7c44 in cp_parser_block_declaration (parser=0x401ab0c0, statement_p=false) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:6030 #13 0x080f7afd in cp_parser_declaration (parser=0x0) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:5950 #14 0x080f79a8 in cp_parser_declaration_seq_opt (parser=0x0) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:5859 #15 0x080f4062 in cp_parser_translation_unit (parser=0x401ab0c0) at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:2136 #16 0x081013e1 in c_parse_file () at /home/zack/src/gcc/vanilla/gcc/cp/parser.c:14314 #17 0x0817b31b in c_common_parse_file (set_yydebug=1073841056) at /home/zack/src/gcc/vanilla/gcc/c-opts.c:1212 #18 0x083bbe2a in compile_file () at /home/zack/src/gcc/vanilla/gcc/toplev.c:1749 #19 0x083c06ee in do_compile () at /home/zack/src/gcc/vanilla/gcc/toplev.c:4526 #20 0x083c0805 in toplev_main (argc=1073841056, argv=0xbfffe0b4) at /home/zack/src/gcc/vanilla/gcc/toplev.c:4567 #21 0x400434ad in __libc_start_main () from /lib/libc.so.6 The offending LABEL_STMT: <label_stmt 0x4019cf14 tree_1 chain <expr_stmt 0x4019cf3c tree_1 arg 0 <call_expr 0x40021300 type <void_type 0x4015bb64 void> side-effects arg 0 <addr_expr 0x4019cf28 type <pointer_type 0x401a9a8c> constant arg 0 <function_decl 0x401a9654 b>>> chain <goto_stmt 0x4019cf50 tree_1 arg 0 <label_decl 0x401a9a20 l> chain <scope_stmt 0x4019cf64 tree_1>>>> LABEL_STMT_LABEL for this is NULL.
I can confirm gcc ICE on the mainline (20030719) and it did not ICE on 2.95.3
Also using Phil's regression hunter, 2000-12-31 ICE's also. Also 2.96 20000731 (Red Hat Linux 7.2 2.96-109) (yes I know that is not a released version but still), it also ICEs.
Created attachment 4504 [details] This should fix it
Steven: please add the test case to the C++ test suite, verify with a bootstrap cycle, and send a complete patch to gcc-patches.
It _is_ a regression, after all.
Steven, did you close the PR by accident? It still fails for me as of this night, and I don't see any CVS commits in the audit trail. W.
Still fails.
Subject: RE: [3.3/3.4 Regresion] crash on duplicate label definition Well, if I closed it something went wrong. I want to "accept" the bug as one that I will formally submit a patch for soon. -----Original Message----- From: bangerth at dealii dot org To: steven@gcc.gnu.org Sent: 9/4/03 4:37 PM Subject: [Bug c++/11595] [3.3/3.4 Regresion] crash on duplicate label definition PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11595 bangerth at dealii dot org changed: What |Removed |Added ------------------------------------------------------------------------ ---- CC| |steven at gcc dot gnu dot | |org Last reconfirmed|2003-09-04 10:04:28 |2003-09-04 14:37:30 date| | ------- Additional Comments From bangerth at dealii dot org 2003-09-04 14:37 ------- Steven, did you close the PR by accident? It still fails for me as of this night, and I don't see any CVS commits in the audit trail. W. ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
Repeat after me: RADIO BUTTONS SUCK
Oh great, and now Bugzilla let's me assign to "unassigned at gcc.gnu.org", WTF!?
Comment on attachment 4504 [details] This should fix it Index: decl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v retrieving revision 1.1121 diff -c -p -3 -r1.1121 decl.c *** decl.c 4 Sep 2003 03:18:02 -0000 1.1121 --- decl.c 6 Sep 2003 14:12:36 -0000 *************** check_goto (tree decl) *** 4937,4944 **** } /* Define a label, specifying the location in the source file. ! Return the LABEL_DECL node for the label, if the definition is valid. ! Otherwise return 0. */ tree define_label (location_t location, tree name) --- 4937,4943 ---- } /* Define a label, specifying the location in the source file. ! Return the LABEL_DECL node for the label. */ tree define_label (location_t location, tree name) *************** define_label (location_t location, tree *** 4961,4970 **** pedwarn ("label named wchar_t"); if (DECL_INITIAL (decl) != NULL_TREE) ! { ! error ("duplicate label `%D'", decl); ! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); ! } else { /* Mark label as having been defined. */ --- 4960,4966 ---- pedwarn ("label named wchar_t"); if (DECL_INITIAL (decl) != NULL_TREE) ! error ("duplicate label `%D'", decl); else { /* Mark label as having been defined. */ *************** define_label (location_t location, tree *** 4977,4985 **** ent->binding_level = current_binding_level; } check_previous_gotos (decl); - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl); } ! timevar_pop (TV_NAME_LOOKUP); } struct cp_switch --- 4973,4981 ---- ent->binding_level = current_binding_level; } check_previous_gotos (decl); } ! ! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl); } struct cp_switch
Fixed for mainline
Subject: Bug 11595 CVSROOT: /cvs/gcc Module name: gcc Changes by: steven@gcc.gnu.org 2003-09-06 15:44:35 Modified files: gcc/cp : decl.c ChangeLog Log message: PR c++/11595 * decl.c (define_label): Remove unreachable timevar pop. Always return the decl, even if the definition is invalid. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1121&r2=1.1122 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3650&r2=1.3651
Subject: Bug 11595 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: steven@gcc.gnu.org 2003-09-09 07:20:48 Modified files: gcc/cp : ChangeLog decl.c Log message: PR c++/11595 * decl.c (define_label): Remove unreachable timeva pop. Always return the decl, even if the definition is invalid. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.204&r2=1.3076.2.205 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.60&r2=1.965.2.61
fixed