https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112588
Nathaniel Shead <nathanieloshead at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nathanieloshead at gmail dot com --- Comment #1 from Nathaniel Shead <nathanieloshead at gmail dot com> --- Minimised (the actual offender here is the with std::allocator<char>): // test.h void f(int*); template <typename T> struct S { void g(int n) { f(&n); } }; template struct S<void>; // a.cpp module; #include "test.h" export module test; // b.cpp #include "test.h" import test; So far it seems the issue is that the PARM_DECL in the expression tree of the body of the instantiation for `S<void>::g` is a different node from the actual PARM_DECL in g's DECL_ARGUMENTS; the latter gets RTL but the former does not. The issue is in the deduplication logic for instantiations somewhere. The following patch fixes this issue but causes other issues in the testsuite, and I don't think this is the correct approach anyway: diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 4f5b6e2747a..f2d191fc408 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -8302,9 +8302,7 @@ trees_in::decl_value () if (TREE_CODE (inner) == FUNCTION_DECL) { tree e_inner = STRIP_TEMPLATE (existing); - for (auto parm = DECL_ARGUMENTS (inner); - parm; parm = DECL_CHAIN (parm)) - DECL_CONTEXT (parm) = e_inner; + DECL_ARGUMENTS (inner) = DECL_ARGUMENTS (e_inner); } /* And our result is the existing node. */ (I was originally working on this after attempting to reduce PR99999.)