]> gcc.gnu.org Git - gcc.git/commit
c++: c->B::m access resolved through current inst [PR116320]
authorPatrick Palka <ppalka@redhat.com>
Thu, 15 Aug 2024 14:23:54 +0000 (10:23 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 15 Aug 2024 14:23:54 +0000 (10:23 -0400)
commit484f139ccd3b631a777802e810a632678b42ffab
tree25aad0b8e17d149fa1b390862a8203e1de570228
parent303bed670af962c01b77a4f0c51de97f70e8167e
c++: c->B::m access resolved through current inst [PR116320]

Here when checking the access of (the injected-class-name) B in c->B::m
at parse time, we notice its context B (now the type) is a base of the
object type C<T>, so we proceed to use C<T> as the effective qualifying
type.  But this C<T> is the dependent specialization not the primary
template type, so it has empty TYPE_BINFO, which leads to a segfault later
from perform_or_defer_access_check.

The reason the DERIVED_FROM_P (B, C<T>) test guarding this code path works
despite C<T> having empty TYPE_BINFO is because of its currently_open_class
logic (added in r9-713-gd9338471b91bbe) which replaces a dependent
specialization with the primary template type if we're inside it.  So the
safest fix seems to be to call currently_open_class in the caller as well.

PR c++/116320

gcc/cp/ChangeLog:

* semantics.cc (check_accessibility_of_qualified_id): Try
currently_open_class when using the object type as the
effective qualifying type.

gcc/testsuite/ChangeLog:

* g++.dg/template/access42.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/template/access42.C [new file with mode: 0644]
This page took 0.066817 seconds and 6 git commands to generate.