[Bug c++/122509] Base template class name lookup only with qualified names
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 19 11:14:50 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122509
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:d19b95ca96f2e10732007d9cd59e6430df8d0b2a
commit r16-6274-gd19b95ca96f2e10732007d9cd59e6430df8d0b2a
Author: Egas Ribeiro <egas.g.ribeiro@gmail.com>
Date: Sat Dec 13 20:06:09 2025 +0000
c++: Fix injected-class-name lookup with multiple bases [PR122509]
When looking up an unqualified injected-class-name in a member access
expression (e.g., D().v<int>), cp_parser_lookup_name calls lookup_member
with protect=0, causing it to return NULL on ambiguity instead of the
candidate list. This prevented the existing DR 176 logic in
maybe_get_template_decl_from_type_decl from resolving the ambiguity.
Per DR 176, if all ambiguous candidates are instantiations of the same
class template and the name is followed by a template-argument-list,
the reference is to the template itself and is not ambiguous.
Fix by using protect=2 to return the ambiguous candidate list.
PR c++/122509
gcc/cp/ChangeLog:
* parser.cc (cp_parser_lookup_name): Use protect=2 instead of
protect=0 when calling lookup_member.
gcc/testsuite/ChangeLog:
* g++.dg/tc1/dr176-2.C: New test.
Signed-off-by: Egas Ribeiro <egas.g.ribeiro@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list