g++ crashes on the (invalid) code below:
$ g++ -c x.cc x.cc: In function 'void foo(void*)': x.cc:4: error: invalid use of undefined type 'struct C' x.cc:1: error: forward declaration of 'struct C' x.cc:4: 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. $ Here's where it's crashing: Program received signal SIGSEGV, Segmentation fault. lookup_member (xbasetype=0x0, name=0x40032bfc, protect=1, want_type=0 '\0') at /home/sss/gcc/gcc/gcc/cp/search.c:1202 1202 if (TREE_CODE (xbasetype) == TREE_BINFO) (gdb) where #0 lookup_member (xbasetype=0x0, name=0x40032bfc, protect=1, want_type=0 '\0') at /home/sss/gcc/gcc/gcc/cp/search.c:1202 #1 0x08127e05 in lookup_fnfields (xbasetype=0x40032bfc, name=0x40032bfc, protect=1073949692) at /home/sss/gcc/gcc/gcc/cp/search.c:1293 #2 0x080508fb in build_op_delete_call (code=171, addr=0x4008dea0, size=0x400251b0, global_p=0 '\0', placement=0x0) at /home/sss/gcc/gcc/gcc/cp/call.c:3936 #3 0x0811bf9c in build_x_delete (addr=0x40032bfc, which_delete=0, virtual_size=0x40032bfc) at /home/sss/gcc/gcc/gcc/cp/init.c:2661 #4 0x0811cc95 in build_vec_delete_1 (base=0x4008dea0, maxindex=0x4008dec0, type=Variable "type" is not available. ) at /home/sss/gcc/gcc/gcc/cp/init.c:2297 #5 0x0811cefc in build_vec_delete (base=0x4008dea0, maxindex=0x4008dec0, auto_delete_vec=sfk_deleting_destructor, use_global_delete=0) at /home/sss/gcc/gcc/gcc/cp/init.c:3029 #6 0x080f5cc0 in cp_parser_delete_expression (parser=0x400b6924) at /home/sss/gcc/gcc/gcc/cp/parser.c:5115 #7 0x080ee408 in cp_parser_unary_expression (parser=0x400b6924, address_p=0 '\0') at /home/sss/gcc/gcc/gcc/cp/parser.c:4665 #8 0x080ef3c8 in cp_parser_assignment_expression (parser=0x400b6924) at /home/sss/gcc/gcc/gcc/cp/parser.c:5317 #9 0x080f09e7 in cp_parser_expression (parser=0x400b6924) at /home/sss/gcc/gcc/gcc/cp/parser.c:5612 #10 0x080f0c97 in cp_parser_expression_statement (parser=0x400b6924, ) at /home/sss/gcc/gcc/gcc/cp/parser.c:6009 #11 0x080e964c in cp_parser_statement (parser=0x400b6924, in_statement_expr=0x0) at /home/sss/gcc/gcc/gcc/cp/parser.c:5893 #12 0x080e9fb1 in cp_parser_statement_seq_opt (parser=0x400b6924, in_statement_expr=0x0) at /home/sss/gcc/gcc/gcc/cp/parser.c:6075 #13 0x080ea0b5 in cp_parser_compound_statement (parser=0x400b6924, in_statement_expr=0x0, in_try=Variable "in_try" is not available. ) at /home/sss/gcc/gcc/gcc/cp/parser.c:6048 #14 0x080ea158 in cp_parser_ctor_initializer_opt_and_function_body ( parser=0x400b6924) at /home/sss/gcc/gcc/gcc/cp/parser.c:11909 #15 0x080ea6c7 in cp_parser_function_definition_after_declarator ( parser=0x400b6924, inline_p=0 '\0') at /home/sss/gcc/gcc/gcc/cp/parser.c:14755 #16 0x080f68e5 in cp_parser_init_declarator (parser=0x400b6924, decl_specifiers=0xbffff158, function_definition_allowed_p=1 '\001', member_p=0 '\0', declares_class_or_enum=Variable "declares_class_or_enum" is not available. ) at /home/sss/gcc/gcc/gcc/cp/parser.c:14700 #17 0x080f6ae9 in cp_parser_simple_declaration (parser=0x400b6924, function_definition_allowed_p=1 '\001') at /home/sss/gcc/gcc/gcc/cp/parser.c:6928 #18 0x080e89aa in cp_parser_block_declaration (parser=0x400b6924, statement_p=0 '\0') at /home/sss/gcc/gcc/gcc/cp/parser.c:6837 #19 0x080f8c64 in cp_parser_declaration (parser=0x400b6924) at /home/sss/gcc/gcc/gcc/cp/parser.c:6754 Environment: System: Linux karma 2.6.8.1 #20 Mon Sep 13 23:48:47 EDT 2004 i686 i686 i386 GNU/Linux Architecture: i686 <machine, os, target, libraries (multiple lines)> host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: /home/sss/gcc/gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long --enable-languages=c,c++,f95 How-To-Repeat: ----------------------------------- class C; void foo(void *p) { delete [] ((C*)p); } ----------------------------------- ------- Additional Comments From snyder at fnal dot gov 2005-02-07 20:13 ------- Fix: <how to correct or work around the problem, if known (multiple lines)> -- Summary: g++ 4.0: ICE on vector delete of undefined class Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: snyder at fnal dot gov CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19811