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++/107532] [13 Regression] -Werror=dangling-reference false positives in libcamera-0.0.1
Date: Tue, 07 Mar 2023 16:11:12 +0000	[thread overview]
Message-ID: <bug-107532-4-xyRF46E01l@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107532-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:80f0052b3924569af904d1bab0858fe985f33a94

commit r13-6529-g80f0052b3924569af904d1bab0858fe985f33a94
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Jan 17 17:34:58 2023 -0500

    c++: -Wdangling-reference with reference wrapper [PR107532]

    Here, -Wdangling-reference triggers where it probably shouldn't, causing
    some grief.  The code in question uses a reference wrapper with a member
    function returning a reference to a subobject of a non-temporary object:

      const Plane & meta = fm.planes().inner();

    I've tried a few approaches, e.g., checking that the member function's
    return type is the same as the type of the enclosing class (which is
    the case for member functions returning *this), but that then breaks
    Wdangling-reference4.C with std::optional<std::string>.

    This patch adjusts do_warn_dangling_reference so that we look through
    reference wrapper classes (meaning, has a reference member and a
    constructor taking the same reference type, or is std::reference_wrapper
    or std::ranges::ref_view) and don't warn for them, supposing that the
    member function returns a reference to a non-temporary object.

            PR c++/107532

    gcc/cp/ChangeLog:

            * call.cc (reference_like_class_p): New.
            (do_warn_dangling_reference): Add new bool parameter.  See through
            reference_like_class_p.

    gcc/testsuite/ChangeLog:

            * g++.dg/warn/Wdangling-reference8.C: New test.
            * g++.dg/warn/Wdangling-reference9.C: New test.

  parent reply	other threads:[~2023-03-07 16:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05  5:48 [Bug c++/107532] New: " slyfox at gcc dot gnu.org
2022-11-05 10:58 ` [Bug c++/107532] " rguenth at gcc dot gnu.org
2022-11-11 20:27 ` mpolacek at gcc dot gnu.org
2022-11-21 10:20 ` marxin at gcc dot gnu.org
2022-12-23  8:28 ` marxin at gcc dot gnu.org
2023-01-13 12:39 ` rguenth at gcc dot gnu.org
2023-01-16 16:43 ` mpolacek at gcc dot gnu.org
2023-01-24 17:38 ` jakub at gcc dot gnu.org
2023-01-24 17:41 ` mpolacek at gcc dot gnu.org
2023-01-24 17:44 ` jakub at gcc dot gnu.org
2023-01-24 17:50 ` mpolacek at gcc dot gnu.org
2023-02-01 14:44 ` pobrn at protonmail dot com
2023-02-14 13:31 ` ecurtin at redhat dot com
2023-02-14 13:45 ` mpolacek at gcc dot gnu.org
2023-03-07 16:11 ` cvs-commit at gcc dot gnu.org [this message]
2023-03-07 16:11 ` mpolacek at gcc dot gnu.org
2023-03-08 11:00 ` marxin at gcc dot gnu.org
2023-03-09 11:47 ` marxin at gcc dot gnu.org
2023-03-10 16:46 ` mpolacek at gcc dot gnu.org
2023-03-10 16:52 ` redi at gcc dot gnu.org
2023-03-10 17:02 ` pobrn at protonmail dot com
2023-03-10 17:17 ` mpolacek at gcc dot gnu.org
2023-03-10 17:18 ` mpolacek at gcc dot gnu.org
2023-03-12 10:49 ` eike@sf-mail.de
2023-03-12 13:37 ` flast at flast dot jp
2023-03-13 15:21 ` cvs-commit at gcc dot gnu.org
2023-03-13 15:53 ` mpolacek at gcc dot gnu.org
2023-03-14 23:09 ` flast at flast dot jp
2023-03-16 15:51 ` mpolacek at gcc dot gnu.org
2023-03-16 16:24 ` mpolacek at gcc dot gnu.org
2023-03-23 13:32 ` cvs-commit at gcc dot gnu.org
2023-03-23 13:33 ` mpolacek at gcc dot gnu.org
2023-03-23 15:22 ` gcc-bugzilla at al42and dot me
2023-04-11 16:09 ` gnu.ojxq8 at dralias dot com
2023-04-12 19:46 ` gnu.ojxq8 at dralias dot com
2023-04-12 19:49 ` mpolacek at gcc dot gnu.org
2023-04-27 22:29 ` cuzdav at gmail dot com
2023-06-12  3:25 ` boris at kolpackov dot net
2023-06-12 16:27 ` mpolacek 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-107532-4-xyRF46E01l@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).