http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47209
--- Comment #5 from Zdenek Sojka <zsojka at seznam dot cz> 2011-01-09 01:17:54 UTC --- Created attachment 22933 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22933 different testcase (In reply to comment #4) > Well, the issue here seems to be that in should_emit_struct_debug > TYPE_STUB_DECL (type) for provided type is a NULL_TREE. In next two > if-statements this result is used unconditionally. I am not sure if the > underlying issue is related to some other place in c++ FE (I assume so), but > following patch at least avoid segfault. It fixes attached testcase as well: Without patch: $ gcc -fopenmp -femit-struct-debug-reduced -g pr47209-2.C ==10408== Invalid read of size 2 ==10408== at 0x78AD70: should_emit_struct_debug (dwarf2out.c:624) ==10408== by 0x7B9790: gen_tagged_type_die (dwarf2out.c:20117) ==10408== by 0x7BA774: gen_typedef_die.part.160 (dwarf2out.c:20266) ==10408== by 0x7B84BB: gen_decl_die (dwarf2out.c:21056) ==10408== by 0x7AC9BD: gen_type_die_with_usage (dwarf2out.c:20412) ==10408== by 0x7AD0F5: gen_type_die_with_usage (dwarf2out.c:20454) ==10408== by 0x7B8355: gen_decl_die (dwarf2out.c:21119) ==10408== by 0x7B5DFE: gen_subprogram_die (dwarf2out.c:19330) ==10408== by 0x7B8142: gen_decl_die (dwarf2out.c:21033) ==10408== by 0x7BB678: dwarf2out_function_decl (dwarf2out.c:21415) ==10408== by 0x8141FC: rest_of_handle_final (final.c:4296) ==10408== by 0x93B5D5: execute_one_pass (passes.c:1553) ==10408== by 0x93B8C4: execute_pass_list (passes.c:1608) ==10408== by 0x93B8D6: execute_pass_list (passes.c:1609) ==10408== by 0x93B8D6: execute_pass_list (passes.c:1609) ==10408== by 0xA7B995: tree_rest_of_compilation (tree-optimize.c:422) ==10408== by 0xC40D21: cgraph_expand_function (cgraphunit.c:1519) ==10408== by 0xC436DC: cgraph_optimize (cgraphunit.c:1672) ==10408== by 0xC43969: cgraph_finalize_compilation_unit (cgraphunit.c:1042) ==10408== by 0x5B7E2C: cp_write_global_declarations (decl2.c:3974) ==10408== by 0xA25165: toplev_main (toplev.c:591) ==10408== by 0x6369BBC: (below main) (in /lib64/libc-2.11.2.so) ==10408== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==10408== pr47209-2.C: In function '<built-in>': pr47209-2.C:9:9: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. With patch: $ gcc -fopenmp -femit-struct-debug-reduced -g pr47209-2.C -c (no output)