[Bug c++/122494] [13/14/15/16 Regression] gcc rejects valid C++ codes with generic lambda and concepts; causing a not completed class
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 27 03:03:32 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122494
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:9cb5c879e722bb63d5ff5621cd77f402cb94a316
commit r16-7055-g9cb5c879e722bb63d5ff5621cd77f402cb94a316
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Jan 26 21:59:48 2026 -0500
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>
More information about the Gcc-bugs
mailing list