I've find out that compiler may crash with SEGFAULT on some openmp-enabled code (attached as debug-1.c) called with the following flags: -g -fopenmp -gdwarf-2 -femit-struct-debug-reduced Also, can be reproduced with -femit-struct-debug-baseonly
The problem is in dwarf2out.c:350:should_emit_struct_debug() at this line: 366 type_decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (type)); In some cases type_decl can be NULL and this causes ICE in the following code: 368 if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl)) 369 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true); 370 371 if (matches_main_base (DECL_SOURCE_FILE (type_decl))) 372 return DUMP_GSTRUCT (type, usage, criterion, generic, true, true); Can be fixed with checking for type_decl is not NULL. I've attached patch to fix this. Could you check, is it ok? This is very straightforward fix, can the problem be in incorrect debug info generation on early stages? Report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57737 Problem is actual since gcc-4.4 as far as I checked. /* With optimism, Evgeny Gavrin email : evgeny.gav...@hotmail.com */
omp-emit-reduced.patch
Description: Binary data
int f7 (void) { int v7i = 6, v7j = 7, v7k = 9, v7l = 0, v7n = 0, v7o = 1; #pragma omp parallel { #pragma omp master v7o++; #pragma omp for private (v7i) firstprivate (v7k) reduction (+:v7l) for (v7n = 0; v7n < 3; v7n++) { int v7m = v7j + v7k; v7i = 8; v7l++; } } return v7i + v7j + v7k + v7l + v7n; } int main (void) { f7 (); return 0; }