-
Notifications
You must be signed in to change notification settings - Fork 12.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
[Clang] if constexpr
inside variable template of generic lambda leads to assertion error or invalid instantiations
#97881
Comments
if constexpr
inside "recursive" variable template lambda leads to assertion error or invalid instantiationsif constexpr
inside variable template of generic lambda leads to assertion error or invalid instantiations
@llvm/issue-subscribers-clang-frontend Author: Mital Ashok (MitalAshok)
This has an assertion error: https://godbolt.org/z/bbd89P7jc
template<int N>
auto g = [](int i) {
if constexpr (N < 4) {
g<N+1>(i);
}
};
int main() {
g<0>(0);
} But it compiles correctly without assertions enabled. This has an assertion error too: https://godbolt.org/z/j1Kr8vK67 template<int N>
auto g = [](auto i) {
if (N < sizeof(i)) {
g<N+1>(i);
}
};
int main() {
g<0>(0);
}
But when run without assertions it seems to ignore the
This one has no assertion error but still compiles wrong: https://godbolt.org/z/n8P4reaob template<int X>
void f() {
static_assert(X != sizeof(int));
}
template<>
void f<sizeof(int)>() = delete;
template<int N>
auto g = [](auto i) {
if constexpr (N != sizeof(i)) {
f<N>();
}
};
int main() {
g<0>(0);
g<sizeof(int)>(0);
}
So seems like it's a problem when the |
This bug is likely related to P0588R1 (tracking via #61426, delayed instantiation of But the first case is not a generic lambda |
The crash and the template<bool B>
auto g = sizeof(g<!B>);
int main() {
// Invalid: instantiating g<false> instantiates g<true> which uses g<false> before the auto type is deduced
(void)sizeof(g<false>);
} So to do with placeholder types and variable templates |
This has an assertion error: https://godbolt.org/z/bbd89P7jc
But it compiles correctly without assertions enabled.
This has an assertion error too: https://godbolt.org/z/j1Kr8vK67
But when run without assertions it seems to ignore the
if constexpr
and instantiateg<N+1>
forever: https://godbolt.org/z/hhhhb8fhjThis one has no assertion error but still compiles wrong: https://godbolt.org/z/n8P4reaob
So seems like it's a problem when the
if constexpr
is dependent both on the variable template and the generic lambdaThe text was updated successfully, but these errors were encountered: