diff mbox

Fix PR debug/47361

Message ID m34o93l2ym.fsf@redhat.com
State New
Headers show

Commit Message

Dodji Seketeli Jan. 20, 2011, 8:44 p.m. UTC
Hello,

Consider the example below:

 typedef decltype (nullptr) nullptr_t;
 struct A
 {
   A (nullptr_t = 0);
 };
 A a;

When compiled with -std=gnu++0x -g -feliminate-dwarf2-dups it
crashes saying:
 internal compiler error: in build_abbrev_table, at dwarf2out.c:10477

At some point -feliminate-dwarf2-dups triggers break_out_includes that
assigns a symbol name to each type DIE that is referenced somewhere; and
later in build_abbrev_table that invariant [any referenced type DIE
should have a symbol name] is asserted.

The problem is nullptr is represented with a DW_TAG_unspecified_type
and that kind of DIE is not recognized as a type DIE and as a result
is not assigned a symbol name by break_out_include (via the call to
assign_symbol_names). So the invariant is not honoured.

The one-liner patch below makes DW_TAG_unspecified_type be recognized as
a type DIE.

Tested on x86_64-unknown-linux-gnu against trunk.

Comments

Jason Merrill Jan. 21, 2011, 5:35 p.m. UTC | #1
This change is OK, but I don't think we want decltype(nullptr) to go 
into a comdat CU, so let's test for it in is_comdat_die as well.

Jason
diff mbox

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2309297..bc4c12f 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -9618,6 +9618,7 @@  is_type_die (dw_die_ref die)
     case DW_TAG_packed_type:
     case DW_TAG_volatile_type:
     case DW_TAG_typedef:
+    case DW_TAG_unspecified_type:
       return 1;
     default:
       return 0;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C
new file mode 100644
index 0000000..54f597e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C
@@ -0,0 +1,11 @@ 
+// Origin PR debug/47361
+// { dg-options "-g -std=gnu++0x -feliminate-dwarf2-dups" }
+
+typedef decltype (nullptr) nullptr_t;
+
+struct A
+{
+  A (nullptr_t = 0);
+};
+
+A a;