[Bug c++/11595] New: crash on duplicate label definition

zack at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Jul 19 21:32:00 GMT 2003


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

           Summary: crash on duplicate label definition
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code, error-recovery
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zack at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org

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.



More information about the Gcc-bugs mailing list