According to [expr.const]/14, the result of substitution into an atomic
constraint is manifestly constant-evaluated; this patch adjusts the call
to maybe_constant_value in satisfy_atom to that effect.
gcc/cp/ChangeLog:
PR c++/97051
* constraint.cc (satisfy_atom): Pass true as the
manifestly_const_eval argument to maybe_constant_value.
gcc/testsuite/ChangeLog:
PR c++/97051
* g++.dg/cpp2a/is-constant-evaluated11.C: New test.
result = cxx_constant_value (result);
else
{
- result = maybe_constant_value (result);
+ result = maybe_constant_value (result, NULL_TREE,
+ /*manifestly_const_eval=*/true);
if (!TREE_CONSTANT (result))
result = error_mark_node;
}
--- /dev/null
+// PR c++/97051
+// { dg-do compile { target c++20 } }
+
+namespace std {
+ constexpr inline bool
+ is_constant_evaluated () noexcept
+ {
+ return __builtin_is_constant_evaluated ();
+ }
+}
+
+template<typename>
+ requires (std::is_constant_evaluated())
+constexpr int a = 0;
+
+constexpr int b = a<int>;