-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Default non-type template parameters with immediately invoked lambdas fail with deduction guides #51315
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
Comments
@llvm/issue-subscribers-clang-frontend Author: None (friedkeenan)
| | |
| --- | --- |
| Bugzilla Link | [51973](https://llvm.org/bz51973) |
| Version | trunk |
| OS | Linux |
| CC | @DougGregor,@friedkeenan,@zygoloid |
Extended DescriptionWith the following code, clang claims the defaulted non-type template parameter is not a constant expression, despite it being so (with GCC handling it fine as well): #include <concepts>
template<
typename T,
auto V = []() {
if constexpr (std::same_as<T, int>) {
return 1;
} else {
return 2;
}
}()
>
struct Test {
constexpr Test(T) { }
};
template<typename T>
Test(T) -> Test<T>;
void test() {
Test<int, 1>(1);
} Godbolt link: https://godbolt.org/z/jT3zPx9fx As you can see, even if you specify the template parameters when constructing, it still complains, and if you duplicate the immediately invoked lambda in the deduction guide and remove the explicated template arguments for the constructor, clang actually says that it can't compile that expression yet. However, if you specify the template arguments, it consumes everything fine. |
@llvm/issue-subscribers-c-20 Author: None (friedkeenan)
| | |
| --- | --- |
| Bugzilla Link | [51973](https://llvm.org/bz51973) |
| Version | trunk |
| OS | Linux |
| CC | @DougGregor,@friedkeenan,@zygoloid |
Extended DescriptionWith the following code, clang claims the defaulted non-type template parameter is not a constant expression, despite it being so (with GCC handling it fine as well): #include <concepts>
template<
typename T,
auto V = []() {
if constexpr (std::same_as<T, int>) {
return 1;
} else {
return 2;
}
}()
>
struct Test {
constexpr Test(T) { }
};
template<typename T>
Test(T) -> Test<T>;
void test() {
Test<int, 1>(1);
} Godbolt link: https://godbolt.org/z/jT3zPx9fx As you can see, even if you specify the template parameters when constructing, it still complains, and if you duplicate the immediately invoked lambda in the deduction guide and remove the explicated template arguments for the constructor, clang actually says that it can't compile that expression yet. However, if you specify the template arguments, it consumes everything fine. |
Still does not work: https://godbolt.org/z/85Mj487hv CC @cor3ntin |
The dependency of lambda doesn't seem right https://godbolt.org/z/6KdT4Tj7Y we crash w/ an assertion enabled |
Uh oh!
There was an error while loading. Please reload this page.
Extended Description
With the following code, clang claims the defaulted non-type template parameter is not a constant expression, despite it being so (with GCC handling it fine as well):
Godbolt link: https://godbolt.org/z/jT3zPx9fx
As you can see, even if you specify the template parameters when constructing, it still complains, and if you duplicate the immediately invoked lambda in the deduction guide and remove the explicated template arguments for the constructor, clang actually says that it can't compile that expression yet. However, if you specify the template arguments, it consumes everything fine.
The text was updated successfully, but these errors were encountered: