public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/106086] New: ICE: trying to capture 'this' in instantiation of generic lambda @ 2022-06-26 5:37 ldalessandro at gmail dot com 2022-07-14 14:20 ` [Bug c++/106086] " ppalka at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: ldalessandro at gmail dot com @ 2022-06-26 5:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106086 Bug ID: 106086 Summary: ICE: trying to capture 'this' in instantiation of generic lambda Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ldalessandro at gmail dot com Target Milestone: --- Following code generates ICE #include <array> #include <concepts> #include <utility> template <int> struct foo { constexpr auto operator()(std::same_as<int> auto...) const -> int { return 0; } }; template <int _size> struct bar : foo<_size> { constexpr auto operator()(std::array<int, _size> index) const -> int { return [&]<std::size_t... i>(std::index_sequence<i...>) { return foo<_size>::operator()(index[i]...); }(std::make_index_sequence<_size>()); } }; bar<1> b; int i = b({0}); // <-- ERROR <source>:18:58: internal compiler error: trying to capture 'this' in instantiation of generic lambda live: https://godbolt.org/z/TKGWME5aG A couple of similar, closed bugs show up in the search so I've added them as see-also. 105788 might be the same but it's listed as "ice-on-invalid-code" and I'm fairly sure mine is valid (it refers to 100291). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106086] ICE: trying to capture 'this' in instantiation of generic lambda 2022-06-26 5:37 [Bug c++/106086] New: ICE: trying to capture 'this' in instantiation of generic lambda ldalessandro at gmail dot com @ 2022-07-14 14:20 ` ppalka at gcc dot gnu.org 2023-10-20 14:50 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: ppalka at gcc dot gnu.org @ 2022-07-14 14:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106086 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-07-14 Status|UNCONFIRMED |NEW CC| |ppalka at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> --- Reduced C++17 ICE-on-valid testcase: template<class> struct foo { int operator()(...) const; }; template<class T> struct bar : foo<T> { auto operator()() const { return [&](auto x) { return foo<T>::operator()(decltype(x){}); }; } }; bar<int> b; int i = b()(0); ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106086] ICE: trying to capture 'this' in instantiation of generic lambda 2022-06-26 5:37 [Bug c++/106086] New: ICE: trying to capture 'this' in instantiation of generic lambda ldalessandro at gmail dot com 2022-07-14 14:20 ` [Bug c++/106086] " ppalka at gcc dot gnu.org @ 2023-10-20 14:50 ` cvs-commit at gcc dot gnu.org 2023-10-20 14:51 ` ppalka at gcc dot gnu.org 2023-10-25 20:21 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-10-20 14:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106086 --- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:909672f02ff75a6a94c88dee4aa41e92edb1d1ed commit r14-4795-g909672f02ff75a6a94c88dee4aa41e92edb1d1ed Author: Patrick Palka <ppalka@redhat.com> Date: Fri Oct 20 10:50:19 2023 -0400 c++: non-static memfn call dependence cleanup [PR106086] In cp_parser_postfix_expression, and in the CALL_EXPR case of tsubst_copy_and_build, we essentially repeat the type-dependent and COMPONENT_REF callee cases of finish_call_expr. This patch deduplicates this logic by making both spots consistently go through finish_call_expr. This allows us to easily fix PR106086 -- which is about us neglecting to capture 'this' when we resolve a use of a non-static member function of the current instantiation only at lambda regeneration time -- by moving the call to maybe_generic_this_capture from the parser to finish_call_expr so that we consider capturing 'this' at regeneration time as well. PR c++/106086 gcc/cp/ChangeLog: * parser.cc (cp_parser_postfix_expression): Consolidate three calls to finish_call_expr, one to build_new_method_call and one to build_min_nt_call_vec into one call to finish_call_expr. Don't call maybe_generic_this_capture here. * pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Remove COMPONENT_REF callee handling. (type_dependent_expression_p): Use t_d_object_e_p instead of t_d_e_p for COMPONENT_REF and OFFSET_REF. * semantics.cc (finish_call_expr): In the type-dependent case, call maybe_generic_this_capture here instead. gcc/testsuite/ChangeLog: * g++.dg/template/crash127.C: Expect additional error due to being able to check the member access expression ahead of time. Strengthen the test by not instantiating the class template. * g++.dg/cpp1y/lambda-generic-this5.C: New test. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106086] ICE: trying to capture 'this' in instantiation of generic lambda 2022-06-26 5:37 [Bug c++/106086] New: ICE: trying to capture 'this' in instantiation of generic lambda ldalessandro at gmail dot com 2022-07-14 14:20 ` [Bug c++/106086] " ppalka at gcc dot gnu.org 2023-10-20 14:50 ` cvs-commit at gcc dot gnu.org @ 2023-10-20 14:51 ` ppalka at gcc dot gnu.org 2023-10-25 20:21 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: ppalka at gcc dot gnu.org @ 2023-10-20 14:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106086 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org Resolution|--- |FIXED Target Milestone|--- |14.0 Status|NEW |RESOLVED --- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- Fixed for GCC 14. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106086] ICE: trying to capture 'this' in instantiation of generic lambda 2022-06-26 5:37 [Bug c++/106086] New: ICE: trying to capture 'this' in instantiation of generic lambda ldalessandro at gmail dot com ` (2 preceding siblings ...) 2023-10-20 14:51 ` ppalka at gcc dot gnu.org @ 2023-10-25 20:21 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: ppalka at gcc dot gnu.org @ 2023-10-25 20:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106086 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also|https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=100291 | CC| |mpolacek at gcc dot gnu.org --- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> --- *** Bug 100291 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-25 20:21 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-06-26 5:37 [Bug c++/106086] New: ICE: trying to capture 'this' in instantiation of generic lambda ldalessandro at gmail dot com 2022-07-14 14:20 ` [Bug c++/106086] " ppalka at gcc dot gnu.org 2023-10-20 14:50 ` cvs-commit at gcc dot gnu.org 2023-10-20 14:51 ` ppalka at gcc dot gnu.org 2023-10-25 20:21 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).