From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4DC26385782B; Tue, 3 Aug 2021 23:28:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DC26385782B From: "StevenSun2021 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101717] [12 Regression] ICE capturing static member within stateless generic lambda Date: Tue, 03 Aug 2021 23:28:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: StevenSun2021 at hotmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 23:28:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101717 --- Comment #5 from Steven Sun --- (In reply to Andrew Pinski from comment #4) Thanks! (In reply to myself from comment #3) > The program seems never think of a situation "a lambda inside a lambda > inside a NSDMI`. We need to amend the logic here. edit to: The program seems never think of a situation "member function call inside a generic lambda inside a lambda inside a NSDMI`. We need to amend the logic here. ------------------------------------- The direct cause of failure is in g:91e534b0d ``` if (!containing_function && !COMPLETE_TYPE_P (closure)) /* If we're parsing a lambda in a non-local class, we can find the fake 'this' in scope_chain. */ init =3D scope_chain->x_current_class_ptr; ``` This part of logic is to find the potential `this` since there is a (static) member function call `f`. Refer to the following comments: /* For the overload resolution we need to find the actual `this` that would be captured if the call turns out to be to a non-static member function. Do not actually capture it at this point. */ // in function `build_new_method_call_1` in `gcc/cp/call.c` ------------------------------------- As for example in comment 1: `scope_chain->x_current_class_ptr` is correctly set when parsing=20 ``` [=3D](auto) { f(); } ``` But it was soon incorrectly set when instantiating the same lambda, i.e. parsing ``` [=3D](auto) { f(); }() ```=20 This failure only affectes the potential `this` pointer inside the ``` [=3D](auto) { f(); } ``` But since here needs no `this` pointer, deleting that problematical `gcc_checking_assert` is actually a potential fix for this problem.=