public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107488] [13 Regression] -Werror=dangling-reference false positives in cppunit Date: Tue, 01 Nov 2022 20:50:34 +0000 [thread overview] Message-ID: <bug-107488-4-Z1uUKXj6S8@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107488-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107488 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-11-01 CC| |mpolacek at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> --- I figure this warning is a false positive since "const int &attribute" refers to one of the int elements of the vector v, not to a temporary object. I think the warning should probably be disabled for operator*, since that returns a reference but doesn't return its parameter: reference operator*() const _GLIBCXX_NOEXCEPT { return *_M_current; } Patch: --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13467,7 +13467,11 @@ do_warn_dangling_reference (tree expr) can be e.g. const int& z = std::min({1, 2, 3, 4, 5, 6, 7}); which doesn't dangle: std::min here returns an int. */ - || !TYPE_REF_OBJ_P (TREE_TYPE (TREE_TYPE (fndecl)))) + || !TYPE_REF_OBJ_P (TREE_TYPE (TREE_TYPE (fndecl))) + /* XXX */ + || (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl) + && DECL_OVERLOADED_OPERATOR_P (fndecl) + && DECL_OVERLOADED_OPERATOR_IS (fndecl, INDIRECT_REF))) return NULL_TREE; /* Here we're looking to see if any of the arguments is a temporary
next prev parent reply other threads:[~2022-11-01 20:50 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-01 8:02 [Bug c++/107488] New: " slyfox at gcc dot gnu.org 2022-11-01 15:56 ` [Bug c++/107488] " pinskia at gcc dot gnu.org 2022-11-01 20:50 ` mpolacek at gcc dot gnu.org [this message] 2022-11-03 19:46 ` cvs-commit at gcc dot gnu.org 2022-11-03 19:48 ` mpolacek at gcc dot gnu.org 2022-11-04 8:14 ` slyfox 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-107488-4-Z1uUKXj6S8@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: linkBe 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).