From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AFCA8385841B; Sun, 19 Dec 2021 19:42:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFCA8385841B From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94376] When nested inside a lambda body, [=] captures by const value instead of by value Date: Sun, 19 Dec 2021 19:42:38 +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: 9.3.1 X-Bugzilla-Keywords: rejects-valid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka 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: Sun, 19 Dec 2021 19:42:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94376 --- Comment #4 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:89cf57ea35d1e0a0b818997c737ac70b7310d9d9 commit r12-6065-g89cf57ea35d1e0a0b818997c737ac70b7310d9d9 Author: Patrick Palka Date: Sun Dec 19 14:42:14 2021 -0500 c++: nested lambda capturing a capture proxy, cont [PR94376] The r12-5403 fix apparently doesn't handle the case where the inner lambda explicitly rather than implicitly captures the capture proxy from the outer lambda, which causes us to reject the first example in the testcase below. This is because compared to an implicit capture, the effective initiali= zer for an explicit capture is wrapped in a location wrapper (pointing to within the capture list), and this wrapper foils the is_capture_proxy check ad= ded in r12-5403. The simplest fix appears to be to strip location wrappers accordingly before checking is_capture_proxy. And to help prevent against this kind of bug, this patch also makes is_capture_proxy assert it doesn't see a location wrapper. PR c++/94376 gcc/cp/ChangeLog: * lambda.c (lambda_capture_field_type): Strip location wrappers before checking for a capture proxy. (is_capture_proxy): Assert that we don't see a location wrapper. (mark_const_cap_r): Don't call is_constant_capture_proxy on a location wrapper. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/lambda/lambda-nested9a.C: New test.=