diff options
| author | Patrick Palka <ppalka@redhat.com> | 2026-01-26 21:59:48 -0500 |
|---|---|---|
| committer | Patrick Palka <ppalka@redhat.com> | 2026-01-26 21:59:48 -0500 |
| commit | 9cb5c879e722bb63d5ff5621cd77f402cb94a316 (patch) | |
| tree | 51b58c8f6f58c250e81cdd630ce474e7bf50095d /libjava/gnu/java/net | |
| parent | e8b4d34ed1df71d6567bc916bd63982c43668dc3 (diff) | |
| download | gcc-9cb5c879e722bb63d5ff5621cd77f402cb94a316.zip gcc-9cb5c879e722bb63d5ff5621cd77f402cb94a316.tar.gz gcc-9cb5c879e722bb63d5ff5621cd77f402cb94a316.tar.bz2 | |
c++: leaky uid-sensitive constexpr evaluation [PR122494, PR123814]
In the PR122494 testcase we constant evaluate 'B<int>::v == 0' first
during warning-dependent folding, which is restricted to avoid unnecessary
template instantiation. During this restricted evaluation we do
decl_constant_value on v which in turn manifestly constant evaluates v's
initializer. But this nested evaluation is incorrectly still restricted
since the restriction mechanism is controlled by a global flag. This
causes constraint checking for A<int> to spuriously fail.
We could narrowly fix this by guarding the decl_constant_value code path
with uid_sensitive_constexpr_evaluation_p but that would overly
pessimize warning-dependent folding of constexpr variables with simple
initializers. The problem is ultimately that the restriction mechanism
is misdesigned, and it shouldn't be a global toggle, instead it should
be local to the constexpr evaluation context and propagated accordingly.
The PR123814 testcase is similar except that the nested manifestly
constant evaluation happens through __fold_builtin_source_location
(which performs arbitrary tsubst).
Until we remove or reimplement the mechanism, this patch disables the
mechanism during nested manifestly constant evaluation. We don't ever
want such evaluation to be restricted since it has semantic consequences.
PR c++/122494
PR c++/123814
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_outermost_constant_expr): Clear
uid_sensitive_constexpr_evaluation_value when mce_true.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-pr122494.C: New test.
* g++.dg/cpp2a/concepts-pr123814.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libjava/gnu/java/net')
0 files changed, 0 insertions, 0 deletions
