-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Nested requires-expression in lambda causes ICE #61779
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-c-20 |
@llvm/issue-subscribers-clang-frontend |
@erichkeane maybe related to #61776 |
Looks similar, but not the same cause apparently. Still crashes after the fix for #61776. |
This one is likely #58872, the problem is we're instantiating the requires constraint before having a call to it. I had a WIP implementation here: https://reviews.llvm.org/D138148 but it wasnt taken over by @cschreib as anticipated. |
@cschreib mentions in the other bug that he's unable to help out with that patch, so I/someone else need to grab it. |
I am trying to implement non-eager lambda instantiation, but I am not that familiar with clang yet, so progress will be relatively slow ;) |
That is great news! I did a quick start above, but never got to spend more than a few minutes on it. Let me know if you get stuck, and I'll help how I can. |
Progress update: I finally make the code in this issue and #58872 and https://reviews.llvm.org/D138148 (the test case provided by cschreib) compile ... |
Handling the implicit capture of #include <type_traits>
struct X {
void f(int) { }
static void f(double) { }
int g() {
auto L = [=](auto a) {
return [](int i) { // expected-note {{explicitly capture 'this'}} expected-note {{while substituting into a lambda}}
return [=](auto b) { // expected-note {{while substituting into a lambda}}
f(decltype(a){}); //expected-error{{this}}
int x = i;
};
};
};
L(3);
return 0;
}
};
int run = X{}.g(); My current implementation does not raise any compile error with this code (because the body is not instantiated). It will only flag an error when the body is instantiated ( If not, could we ONLY skip the instantiation of dependent |
I don't think we could do that. I THINK we still would like to analyze that to see if we can calculate the capture based on everything else. In the example above, we SHOULD be able to diagnose that right away, 'a' clearly cannot be anything else (that is, its type is dependent, but not its lookup). |
I've encountered another example where the body needs to be instantiated to compute the capture set: void bar(auto... v) {}
void foo(auto... v) {
bar([&] { v; } ...);
}
foo(1, 1.0, 'c'); Currently, I plan to execute I'm not sure if this is feasible? Is there a better solution? I've read through P0588R0 several times, and it mentions:
However, I can't figure out how to implement the computation of implicit |
I'm still working on the implmentation. Currently I bypass the instantiation of if constexpr while still processing the remainder of the body. This approach works for both the parameter pack scenario and the implicit this capture case (see comments above). However, this method struggles with parameter packs within constexpr if statements, as demonstrated in this example (gcc just iced.). Additionally, the current method leads to redundant diagnostics. Quoting my previous comment:
I REALLY need some help here @erichkeane @zygoloid |
I experimented with another approach: During However, I think I still require a visitor to address the parameter pack within the |
Sorry for the delay, I was out for 3 months on bonding leave, so jsut catching up now. Sorry if my comment misses past context here... I don't think just skipping the |
The snippet below is derived from GCC's test
concepts-lambda14.C
causes an assertion failure. Unsure if it's a minimal repro, but it's as minimal as I could get it for now.The text was updated successfully, but these errors were encountered: