diff mbox series

c++: ICE with header-units [PR 99071]

Message ID ad4d6188-7c53-f834-1f9c-6897e976eb52@acm.org
State New
Headers show
Series c++: ICE with header-units [PR 99071] | expand

Commit Message

Nathan Sidwell Feb. 17, 2021, 1:31 p.m. UTC
This ICE was caused by dereferencing the wrong pointer and not finding 
the expected thing there.  Pointers	are like that.

         PR c++/99071
         gcc/cp/
         * name-lookup.c	(maybe_record_mergeable_decl): Deref the correct
         pointer.
         gcc/testsuite/
         * g++.dg/modules/pr99071_a.H: New.
         * g++.dg/modules/pr99071_b.H: New.
diff mbox series

Patch

diff --git c/gcc/cp/name-lookup.c w/gcc/cp/name-lookup.c
index 5aa206d40d4..fda987e9616 100644
--- c/gcc/cp/name-lookup.c
+++ w/gcc/cp/name-lookup.c
@@ -3525,7 +3525,7 @@  maybe_record_mergeable_decl (tree *slot, tree name, tree decl)
   if (!partition)
     {
       binding_slot &orig
-	= BINDING_VECTOR_CLUSTER (*gslot, 0).slots[BINDING_SLOT_CURRENT];
+	= BINDING_VECTOR_CLUSTER (*slot, 0).slots[BINDING_SLOT_CURRENT];
 
       if (!STAT_HACK_P (tree (orig)))
 	orig = stat_hack (tree (orig));
diff --git c/gcc/testsuite/g++.dg/modules/pr99071_a.H w/gcc/testsuite/g++.dg/modules/pr99071_a.H
new file mode 100644
index 00000000000..44bc7c43601
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99071_a.H
@@ -0,0 +1,6 @@ 
+// PR 99071 ICE with global-module merging
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+
+template<typename T>
+void begin (T *);
diff --git c/gcc/testsuite/g++.dg/modules/pr99071_b.H w/gcc/testsuite/g++.dg/modules/pr99071_b.H
new file mode 100644
index 00000000000..1c773d74f12
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99071_b.H
@@ -0,0 +1,8 @@ 
+// PR 99071 ICE with global-module merging
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+
+import "pr99071_a.H";
+
+template<typename T>
+void begin(T &);