From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C80B83858C2D; Sun, 12 Mar 2023 10:49:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C80B83858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678618163; bh=XG+rB7ydrM8DImDh2AVDzT2XcN0QMSp2wCtXpNjA7xM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rNVdap44AXQajM51003lcvvsECnLpK9LCDWsWTLWxutpPjOxiIFh7rFGqUTjhrXqw bOL9O++Ii1JblD/o5o7c3Au4bCkLi7gsiAX9L0ETAo1dwuyfIRYVPN9VeOFxzaMDBD cU03MaVE/iU/GOPb91aPMkTzzyNym4mWULL71qb0= From: "eike@sf-mail.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107532] [13 Regression] -Werror=dangling-reference false positives in libcamera-0.0.1 Date: Sun, 12 Mar 2023 10:49:21 +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: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: eike@sf-mail.de X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107532 --- Comment #20 from Rolf Eike Beer --- I'm running this rev: g++-13 (Gentoo 13.0.1.9999 p, commit 27495bc8fe028d4a68e97ad12b52231772e48d= cf) 13.0.1 20230308 (experimental) And I still get a warning for this testcase: // $ cat ref.cpp #include const std::string &trigger(const std::string &server); int verifyDevXml() { const auto &str =3D trigger(""); if (str.empty()) return 1; return 0; } // $ g++-13 -Wdangling-reference -c -o ref.o ref.cpp ref.cpp: In function ?int verifyDevXml()?: ref.cpp:7:15: warning: possibly dangling reference to a temporary [-Wdangling-reference] 7 | const auto &str =3D trigger(""); | ^~~ ref.cpp:7:28: note: the temporary was destroyed at the end of the full expression ?trigger(std::__cxx11::basic_string(((const char*)""), std::allocator()))? 7 | const auto &str =3D trigger(""); | ~~~~~~~^~~~ The problem is to my understanding that this warns about the temporary constructed in the argument, i.e. it warns that the std::string() formed fr= om "" could be bound here. Which could be true if the function does that, but = in my case it is just used as a lookup for a map and not returned.=