Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The expression of static_assert is not an immediate function context #57627

Closed
JohelEGP opened this issue Sep 8, 2022 · 4 comments
Closed

The expression of static_assert is not an immediate function context #57627

JohelEGP opened this issue Sep 8, 2022 · 4 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@JohelEGP
Copy link

JohelEGP commented Sep 8, 2022

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

See https://godbolt.org/z/4GMxo13vv.

#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.

I think static_assert(s().empty()); should also be rejected by Clang.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Sep 8, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 8, 2022

@llvm/issue-subscribers-clang-frontend

@shafik
Copy link
Collaborator

shafik commented Sep 9, 2022

If we look at:

constexpr auto y = s().empty();

it feels like clang is not being consistent. Either s().empty() is a constant expression or not.

@AaronBallman
Copy link
Collaborator

It seems MSVC also accepts what Clang accepts, while ICC rejects the same way GCC does.

@cor3ntin
Copy link
Contributor

All compilers now accept all 4 static_asserts https://godbolt.org/z/naeoWYfWq
Clang was changed in 17.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

6 participants