https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97572

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
But the problem *is* in line 2:

<stdin>:2:63: error: ‘t’ is not a constant expression

To evaluate any(t) in a constant expression you need t to be a constant
expression, and it isn't.

I suppose the diagnostic could be improved to clarify that local parameters of
a requires-expression are never constant expressions.


Clang gives a different error, but I don't think the reason it gives for the
error is actually helpful:

any.C:3:1: error: static_assert failed
static_assert (Any <bool>);
^              ~~~~~~~~~~
any.C:3:16: note: because 'bool' does not satisfy 'Any'
static_assert (Any <bool>);
               ^
any.C:2:68: note: because 'any(t)' would be invalid: constraint variable 't'
cannot be used in an evaluated context
template <typename T> concept Any = requires (T t) { requires any (t); };
                                                                   ^
1 error generated.


"cannot be used in an evaluated context" seems odd given that all expressions
in a requirements-body are unevaluated operands.

Reply via email to