diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-11-03 15:35:18 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-11-03 15:35:18 -0400 |
commit | 40c34beef620ed13c4113c893ed4335ccc1b8f92 (patch) | |
tree | 08e929a363fa50b11f45169d0ea92b8507491e30 /gcc/cp | |
parent | 095de980339f2fe0ff2add112c4d5ab9175b8f58 (diff) | |
download | gcc-40c34beef620ed13c4113c893ed4335ccc1b8f92.zip gcc-40c34beef620ed13c4113c893ed4335ccc1b8f92.tar.gz gcc-40c34beef620ed13c4113c893ed4335ccc1b8f92.tar.bz2 |
c++: requires-expr and access checking [PR107179]
Like during satisfaction, we also need to avoid deferring access checks
during substitution of a requires-expr because the outcome of an access
check can determine the value of the requires-expr. Otherwise (in
deferred access checking contexts such as within a base-clause), the
requires-expr may evaluate to the wrong result, and along the way a
failed access check may leak out from it into a non-SFINAE context and
cause a hard error (as in the below testcase).
PR c++/107179
gcc/cp/ChangeLog:
* constraint.cc (tsubst_requires_expr): Make sure we're not
deferring access checks.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-requires31.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/constraint.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 5e6a3bc..f6ef078 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2252,6 +2252,9 @@ tsubst_requires_expr (tree t, tree args, sat_info info) { local_specialization_stack stack (lss_copy); + /* We need to check access during the substitution. */ + deferring_access_check_sentinel acs (dk_no_deferred); + /* A requires-expression is an unevaluated context. */ cp_unevaluated u; |