From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D1A983858CDB; Wed, 24 Jan 2024 07:50:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1A983858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706082641; bh=ppqtivGMCHtQDKHhFAKKGYWyp5cAB29igSRrQExoHG4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eSRvGge9FMcvAVjyaq89Xd3R7t0uO7mfk4VH2tlM9uaUGA7AgbFmQgwx8Hjp9U8Rn 5uTferVV3hbi5SwCmsYe5FtZljRK6KTMY1L5Wx6Z0g0mEkCZ5SDQ/fgfwV1EXh8R6r 9xhlxfFtUVkkCAHs5pk8nj0ztabHRcghSZoDBouc= From: "ostash at ostash dot kiev.ua" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110075] Bogus -Wdangling-reference Date: Wed, 24 Jan 2024 07:50:41 +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.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: ostash at ostash dot kiev.ua X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D110075 Viktor Ostashevskyi changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ostash at ostash dot kiev.= ua --- Comment #4 from Viktor Ostashevskyi --- I have even simpler reproducer: --- class X{}; const X x1; const X x2; const X& get(const int& i) { return i =3D=3D 0 ? x1 : x2; } void foo() { [[maybe_unused]] const X& x =3D get(10); } --- : In function 'void foo()': :23:31: warning: possibly dangling reference to a temporary [-Wdangling-reference] 23 | [[maybe_unused]] const X& x =3D get(10); | ^ :23:38: note: the temporary was destroyed at the end of the full expression 'get(10)' 23 | [[maybe_unused]] const X& x =3D get(10); |=