public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108165] -Wdangling-reference false positive
Date: Wed, 01 Feb 2023 18:14:12 +0000	[thread overview]
Message-ID: <bug-108165-4-pUB7OHtfsd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108165-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #5)
> Sorry, I'm not sure if the false positive in comment 0 can be fixed.  I
> can't simply compare the type of the temporary argument and the return type,
> because we may be returning a subobject of the temporary argument, which is
> still dangerous.

Well, you could e.g. walk recursively all the TYPE_FIELDS of the type of the
temporary
and compare to the type the return type references.  If the temporary has some
subobject of that type or if the temporary itself has that type, warn,
otherwise not warn.
There would still be false positives and false negatives, but those are without
actually looking at the definition unavoidable.

  parent reply	other threads:[~2023-02-01 18:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-18 17:41 [Bug c++/108165] New: " romain.geissler at amadeus dot com
2022-12-18 17:46 ` [Bug c++/108165] " pinskia at gcc dot gnu.org
2022-12-18 17:47 ` pinskia at gcc dot gnu.org
2022-12-18 18:06 ` romain.geissler at amadeus dot com
2022-12-19  8:41 ` marxin at gcc dot gnu.org
2022-12-19 13:31 ` redi at gcc dot gnu.org
2023-02-01 18:04 ` mpolacek at gcc dot gnu.org
2023-02-01 18:14 ` jakub at gcc dot gnu.org [this message]
2023-02-01 18:20 ` mpolacek at gcc dot gnu.org
2023-02-01 20:40 ` mpolacek at gcc dot gnu.org
2023-02-01 21:55 ` mpolacek at gcc dot gnu.org
2023-02-28  7:32 ` marxin at gcc dot gnu.org
2023-02-28 14:53 ` mpolacek at gcc dot gnu.org
2023-03-02  8:30 ` marxin at gcc dot gnu.org
2023-03-02 16:30 ` mpolacek at gcc dot gnu.org
2023-03-03  7:35 ` marxin at gcc dot gnu.org
2023-03-07 16:14 ` mpolacek at gcc dot gnu.org
2023-04-18  0:55 ` mrsam@courier-mta.com

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-108165-4-pUB7OHtfsd@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).