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

--- Comment #2 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
I think that's different. Actually, I think it's Clang that's wrong. As
mentioned at
https://cpplang.slack.com/archives/C21PKDHSL/p1656857369259539?thread_ts=1656856509.892079&cid=C21PKDHSL:
> The expression of the `static_assert` is not an
> [immediate function 
> context](https://eel.is/c++draft/expr.const#def:immediate_function_context).
> Wrapping it in `[]() consteval { return s().empty(); }()` 
> [works](https://godbolt.org/z/PKTE7zofW),
> whereas removing that `consteval` causes Clang to also complain.

See https://godbolt.org/z/4GMxo13vv.
```C++
#include <string>
consteval auto s() { return std::string(); }
static_assert(s().empty()); // Only Clang accepts.
// static_assert([]() consteval { return s().empty(); }()); // All accept.
// static_assert([]() { return s().empty(); }()); // All reject.
```

Opened https://github.com/llvm/llvm-project/issues/57627 for that.

Reply via email to