public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-94376-4-Wks1cZ5ehQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94376-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94376

--- 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:fd740165e54151ea794fca34904f5c2e2ea1dcda

commit r12-5403-gfd740165e54151ea794fca34904f5c2e2ea1dcda
Author: Patrick Palka <ppalka@redhat.com>
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 capture
    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 outer
    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.

  parent reply	other threads:[~2021-11-19 13:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-28  0:14 [Bug c++/94376] New: " arthur.j.odwyer at gmail dot com
2021-11-02 17:27 ` [Bug c++/94376] " ppalka at gcc dot gnu.org
2021-11-19 13:54 ` cvs-commit at gcc dot gnu.org [this message]
2021-11-19 13:56 ` ppalka at gcc dot gnu.org
2021-12-19 19:42 ` cvs-commit at gcc dot gnu.org
2021-12-28 10:01 ` pinskia at gcc dot gnu.org
2022-04-26 20:26 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94376-4-Wks1cZ5ehQ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).