https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101140
Nathaniel Shead <nshead at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC| |nshead at gcc dot gnu.org Last reconfirmed| |2024-03-26 --- Comment #3 from Nathaniel Shead <nshead at gcc dot gnu.org> --- I believe this should be valid. The declaration of `::operator new` should be reachable within the instantiation context of 'construct_at' , and thus shouldn't need to be exported to be called. (See [module.context] and [module.reach].) The issue looks to be that `tsubst_expr` when handling a NEW_EXPR just calls `build_new`, which ultimately does `build_operator_new_call` that uses normal `lookup_qualified_name (global_namespace, fnname)` that doesn't consider non-exported entities. We need some way to signify that lookup should also consider declarations reachable from other points in the template's instantiation context. This could be related to one of the issues causing PR114275, but in that cases it's failing to find instantiations of friend classes in the instantiation context.