[Bug c++/101140] [modules] no matching function for call to ‘operator new(sizetype, void*)’
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 27 10:51:18 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101140
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:
https://gcc.gnu.org/g:aaa06bae53e5b352a3c7c999e751e31e9e58f249
commit r16-7062-gaaa06bae53e5b352a3c7c999e751e31e9e58f249
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date: Fri Jan 9 17:21:08 2026 +1100
c++/modules: Include instantiation origination for all name lookup
[PR122609]
Many expressions rely on standard library names being visible when used,
such as for structured bindings, typeid, coroutine traits, and so forth.
When these expressions occur in templates, and the instantiations occur
in a TU where those names are not visible, we currently error, even if
the name was visible in the TU the template was defined.
This is a poor user experience (made worse by fixit suggestions to add
an include in the module the template was defined, which wouldn't fix
the error anyway). It seems reasonable to also include declarations that
were visible at the point the instantiation originated.
When using 'import std' this should fix most such errors. If using
traditional #includes to provide the standard library this may or may
not fix the error; in many cases we may still incorrectly discard the
relevant names (e.g. typeid in a template does not currently cause us to
consider std::type_info to be decl-reachable).
This also fixes the XFAIL in adl-12_b.C as we add_candidates now
properly considers names visible in the instantiation context of the
comparison.
PR c++/122609
PR c++/101140
gcc/cp/ChangeLog:
* cp-tree.h (visible_from_instantiation_origination): Declare.
* module.cc: (orig_decl_for_instantiation): New function.
(path_of_instantiation): Use it.
(visible_from_instantiation_origination): New function.
* name-lookup.cc (name_lookup::search_namespace_only): Also find
names visible at the point the instantiation originated.
gcc/testsuite/ChangeLog:
* g++.dg/modules/adl-12_b.C: Remove XFAIL.
* g++.dg/modules/inst-8_a.C: New test.
* g++.dg/modules/inst-8_b.C: New test.
* g++.dg/modules/inst-8_c.C: New test.
* g++.dg/modules/inst-9_a.C: New test.
* g++.dg/modules/inst-9_b.C: New test.
* g++.dg/modules/inst-10_a.C: New test.
* g++.dg/modules/inst-10_b.C: New test.
* g++.dg/modules/inst-10_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list