From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 56B53385C418; Fri, 19 Nov 2021 13:54:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56B53385C418 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: Fri, 19 Nov 2021 13:54:50 +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: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Fri, 19 Nov 2021 13:54:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94376 --- Comment #2 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:fd740165e54151ea794fca34904f5c2e2ea1dcda commit r12-5403-gfd740165e54151ea794fca34904f5c2e2ea1dcda Author: Patrick Palka Date: Fri Nov 19 08:54:25 2021 -0500 c++: nested lambda capturing a capture proxy [PR94376] Here when determining the type of the FIELD_DECL for the by-value captu= re of 'i' in the inner lambda, we incorrectly give it the type const int instead of int since the effective initializer is the proxy for the out= er capture, and this proxy is const since the outer lambda is non-mutable. This patch fixes this by making lambda_capture_field_type handle by-value capturing of capture proxies specially, namely we instead consider the type of their FIELD_DECL which unlike the proxy has the true cv-quals of the captured entity. PR c++/94376 gcc/cp/ChangeLog: * lambda.c (lambda_capture_field_type): Simplify by handling the is_this case first. When capturing by-value a capture proxy, consider the type of the corresponding field instead. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/lambda/lambda-nested9.C: New test.=