-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Clang error when using a constexpr variable as NTTP default value in lambda expression. #107048
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: Luke D'Alessandro (ldalessa)
```c++
void foo()
{
constexpr int x{};
auto a = []<int=x>{};
}
```
Looks like a regression from 16 to 17, persists in 18 and current trunk. |
Now only EDG accepts it. https://godbolt.org/z/h58Ko1rce |
Probably, this has been turned into ill-formed according to P2036R3:
And clues from P2579R0 could also prove this point:
But what confuses me is that we don't appear to diagnose such lambdas containing explicit captures; instead, we just give errors on lambda with no captures. (Which is OP's example) @cor3ntin Could you confirm? |
I want to mention that the real use case I have is in a decltype() for the lambda. I’m not sure if this changes any of the standardese associated with it. I can post a more sophisticated use when I get back to my computer. |
We only check that a default argument is a converted constant expression when using the default argument. However, when parsing a default argument, we need to make sure to parse it as a constant expression such as not ODR-use variables. (otherwise, we would try to capture default template arguments of generic lambdas) Fixes llvm#107048
) We only check that a default argument is a converted constant expression when using the default argument. However, when parsing a default argument, we need to make sure to parse it as a constant expression such as not ODR-use variables. (otherwise, we would try to capture default template arguments of generic lambdas) Fixes #107048
Looks like a regression from 16 to 17, persists in 18 and current trunk.
https://godbolt.org/z/TErqq79ao
The text was updated successfully, but these errors were encountered: