public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix PR debug/47361
@ 2011-01-20 20:58 Dodji Seketeli
  2011-01-21 18:47 ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Dodji Seketeli @ 2011-01-20 20:58 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC Patches

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.

-- 
		Dodji

From 35b20c17096eb9c2838d5e14afc042370f882a26 Mon Sep 17 00:00:00 2001
From: Dodji Seketeli <dodji@redhat.com>
Date: Thu, 20 Jan 2011 15:14:05 +0100
Subject: [PATCH] Fix PR debug/47361

gcc/

	PR debug/47361
	* dwarf2out.c (is_type_die): Consider DW_TAG_unspecified_type as a
	type DIE.

gcc/testsuite/

	PR debug/47361
	* g++.dg/debug/dwarf2/nullptr-1.C: New test.
---
 gcc/dwarf2out.c                               |    1 +
 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C |   11 +++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C

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;
-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix PR debug/47361
  2011-01-20 20:58 Fix PR debug/47361 Dodji Seketeli
@ 2011-01-21 18:47 ` Jason Merrill
  2011-01-24 14:45   ` Dodji Seketeli
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2011-01-21 18:47 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: GCC Patches

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix PR debug/47361
  2011-01-21 18:47 ` Jason Merrill
@ 2011-01-24 14:45   ` Dodji Seketeli
  2011-01-24 16:30     ` Dodji Seketeli
  0 siblings, 1 reply; 4+ messages in thread
From: Dodji Seketeli @ 2011-01-24 14:45 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC Patches

Jason Merrill <jason@redhat.com> writes:

> 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.

Yes. I have therefore tested the patch below on x86_64-unknown-linux-gnu
against trunk.

-- 
		Dodji

From 3d83010ea7215dabd02a0b06bef92c477be59594 Mon Sep 17 00:00:00 2001
From: Dodji Seketeli <dodji@redhat.com>
Date: Thu, 20 Jan 2011 15:14:05 +0100
Subject: [PATCH] Fix PR debug/47361

gcc/

	PR debug/47361
	* dwarf2out.c (is_type_die): Consider DW_TAG_unspecified_type as a
	type DIE.
	(is_comdat_die): Don't put DW_TAG_unspecified_type in a comdat
	section.

gcc/testsuite/

	PR debug/47361
	* g++.dg/debug/dwarf2/nullptr-1.C: New test.
---
 gcc/dwarf2out.c                               |    7 +++++--
 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C |   11 +++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2309297..44a3768 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;
@@ -9635,9 +9636,11 @@ is_comdat_die (dw_die_ref c)
   /* I think we want to leave base types and __vtbl_ptr_type in the main CU, as
      we do for stabs.  The advantage is a greater likelihood of sharing between
      objects that don't include headers in the same order (and therefore would
-     put the base types in a different comdat).  jason 8/28/00 */
+     put the base types in a different comdat).  jason 8/28/00
+     We don't put DW_TAG_unspecified_type in comdat sections either.  */
 
-  if (c->die_tag == DW_TAG_base_type)
+  if (c->die_tag == DW_TAG_base_type
+      || c->die_tag == DW_TAG_unspecified_type)
     return 0;
 
   if (c->die_tag == DW_TAG_pointer_type
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;
-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fix PR debug/47361
  2011-01-24 14:45   ` Dodji Seketeli
@ 2011-01-24 16:30     ` Dodji Seketeli
  0 siblings, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2011-01-24 16:30 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC Patches

Dodji Seketeli <dodji@redhat.com> writes:

> Jason Merrill <jason@redhat.com> writes:
>
>> 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.
>
> Yes. I have therefore tested the patch below on x86_64-unknown-linux-gnu
> against trunk.

Jakub pointed out on IRC that I should test this with -gdwarf4 as well
since that flag makes the compiler take another path to eliminate type
DIE dups. So I have added a test with that flag.

Tested likewise.

-- 
		Dodji

From 86bca56067e18761d479d34bce6878f833bcf46c Mon Sep 17 00:00:00 2001
From: Dodji Seketeli <dodji@redhat.com>
Date: Thu, 20 Jan 2011 15:14:05 +0100
Subject: [PATCH] Fix PR debug/47361

gcc/

	PR debug/47361
	* dwarf2out.c (is_type_die): Consider DW_TAG_unspecified_type as a
	type DIE.
	(is_comdat_die): Don't put DW_TAG_unspecified_type in a comdat
	section.

gcc/testsuite/

	PR debug/47361
	* g++.dg/debug/dwarf2/nullptr-1.C: New test.
---
 gcc/dwarf2out.c                               |    7 +++++--
 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C |   11 +++++++++++
 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C |   11 +++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2309297..44a3768 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;
@@ -9635,9 +9636,11 @@ is_comdat_die (dw_die_ref c)
   /* I think we want to leave base types and __vtbl_ptr_type in the main CU, as
      we do for stabs.  The advantage is a greater likelihood of sharing between
      objects that don't include headers in the same order (and therefore would
-     put the base types in a different comdat).  jason 8/28/00 */
+     put the base types in a different comdat).  jason 8/28/00
+     We don't put DW_TAG_unspecified_type in comdat sections either.  */
 
-  if (c->die_tag == DW_TAG_base_type)
+  if (c->die_tag == DW_TAG_base_type
+      || c->die_tag == DW_TAG_unspecified_type)
     return 0;
 
   if (c->die_tag == DW_TAG_pointer_type
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;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C
new file mode 100644
index 0000000..f6d656c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C
@@ -0,0 +1,11 @@
+// Origin PR debug/47361
+// { dg-options "-g -std=gnu++0x -feliminate-dwarf2-dups -gdwarf-4" }
+
+typedef decltype (nullptr) nullptr_t;
+
+struct A
+{
+  A (nullptr_t = 0);
+};
+
+A a;
-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-24 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-20 20:58 Fix PR debug/47361 Dodji Seketeli
2011-01-21 18:47 ` Jason Merrill
2011-01-24 14:45   ` Dodji Seketeli
2011-01-24 16:30     ` Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).