c++: ICE with header-units [PR 99071]
authorNathan Sidwell <nathan@acm.org>
Wed, 17 Feb 2021 13:28:09 +0000 (05:28 -0800)
committerNathan Sidwell <nathan@acm.org>
Wed, 17 Feb 2021 13:41:37 +0000 (05:41 -0800)
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.

gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/modules/pr99071_a.H [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr99071_b.H [new file with mode: 0644]

index 5aa206d40d4671321c0f6811d93c360b334a3775..fda987e9616966408275fb28eeac3bb8c306cfc2 100644 (file)
@@ -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 a/gcc/testsuite/g++.dg/modules/pr99071_a.H b/gcc/testsuite/g++.dg/modules/pr99071_a.H
new file mode 100644 (file)
index 0000000..44bc7c4
--- /dev/null
@@ -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 a/gcc/testsuite/g++.dg/modules/pr99071_b.H b/gcc/testsuite/g++.dg/modules/pr99071_b.H
new file mode 100644 (file)
index 0000000..1c773d7
--- /dev/null
@@ -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 &);