-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Fail to consider a member access from an object to a static member a constant expression #57254
Comments
@llvm/issue-subscribers-clang-frontend |
Using |
Right, I was looking at this from the perspective of the type being hidden due to a macro that defines a template function. In any case, I have workarounds, it's not a show-stopper of a problem, but just really intriguing that the build only fails on Linux. |
Wait, where's a macro involved? And where a template function? I was thinking it might be due to a different stdlib, but struct Usertype
{
static constexpr bool getSomething()
{
return true;
}
};
void checkSomething(Usertype& ud)
{
if constexpr (ud.getSomething()) {}
} Also reproduces. |
Not in the example, but just explaining how I was looking at it that I didn't think of |
This looks very closely related to #56246 -- that one is about resolving to a static data member of |
@llvm/issue-subscribers-c-11 |
struct Foo {
static constexpr bool Bar() { return true; }
};
void func(Foo& foo) {
static_assert(foo.Bar());
} https://godbolt.org/z/4add9zche Related discussions: #40438 Can you confirm @AaronBallman |
I think this is the subject of https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2280r4.html which we don't claim to implement yet. (Thanks @shafik for noticing that connection!) |
Should be fixed by #63139 |
Closing as duplicate of #63139. |
This compiles fine on Windows, but on Linux I get "constexpr if condition is not a constant expression".
Tested against clang versions:
Using C++17 in all instances.
The text was updated successfully, but these errors were encountered: