[Bug c++/88694] constexpr isn't captured correctly in lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88694 --- Comment #6 from Jonathan Wakely --- Fixed by r11-88: c++: Avoid inconsistency in lambda fn's this pointer name [pr94807] * coroutines.cc (morph_fn_to_coro): Just check for closure_identifier. * pt.c (tsubst_function_decl): Update lambda fn's this_ptr name. We could add the testcase from comment 4.
[Bug c++/88694] constexpr isn't captured correctly in lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88694 Andrew Pinski changed: What|Removed |Added Known to fail||10.3.0 Known to work||11.1.0 --- Comment #5 from Andrew Pinski --- Seems fixed in GCC 11+.
[Bug c++/88694] constexpr isn't captured correctly in lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88694 ensadc at mailnesia dot com changed: What|Removed |Added CC||ensadc at mailnesia dot com --- Comment #4 from ensadc at mailnesia dot com --- Further reduced: template struct A { static constexpr T e = U; constexpr operator int () { return e; } }; struct D { template void print (); }; int main () { D d; [&](auto i) { auto x = [&] { d.print(); }; }(A{}); }
[Bug c++/88694] constexpr isn't captured correctly in lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88694 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2019-01-04 CC||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org, ||redi at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #3 from Jakub Jelinek --- Reduced testcase with no headers, clang++ -std=c++17 accepts this. template struct A { static constexpr T e = U; constexpr operator int () { return e; } }; template struct B {}; template using C #ifdef __clang__ = __make_integer_seq; #else = B; #endif template void foo (U f, B) { (f (A{}), ...); } template void bar (U f) { foo (f, C{}); } struct D { template void print (); }; int main () { D d; bar ([&](auto i) { auto x = [&] { d.print(); }; }); } Older versions of g++ reject it with ‘__closure’ is not a constant expression instead and before r248384 it is rejected because __integer_pack hasn't been implemented.
[Bug c++/88694] constexpr isn't captured correctly in lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88694 --- Comment #2 from Amos Bird --- Currently by introducing a `auto local_i = decltype(i)();` can workaround this. #include #include #include template constexpr void static_for_impl(Func&& f, std::integer_sequence) { (f(std::integral_constant{}), ...); } template constexpr void static_for(Func&& f) { static_for_impl(std::forward(f), std::make_integer_sequence{}); } struct Foo { template void print() { std::cout << x << std::endl; } }; int main() { Foo foo; static_for([&](auto i) { [&]() { auto local_i = decltype(i)(); foo.print(); }(); }); return 0; }
[Bug c++/88694] constexpr isn't captured correctly in lambda
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88694 --- Comment #1 from Amos Bird --- Created attachment 45343 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45343=edit the ii file