From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EA8D53858C60; Wed, 26 Apr 2023 23:24:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA8D53858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682551445; bh=xE3WhyKKK2EPTO9OjlebibRDUnFAu6RFlMu2iYoy7Ys=; h=From:To:Subject:Date:From; b=C154apLa/7ToUa/zTq08IU/5ltcPNPIOvp4AsX5+vJOSg0so20yeAMi15ziYlPS9/ 7EmeESNPXD7HxpmbfR20tT7kc7X9N0u2RfXOSbZs1TBvusNzE3PxoenzQ4RPyN23Fu 0OLMMbgMp4zLnQbCrR2VKkhGzGUjKmXFCWNcSDjA= From: "ed at catmur dot uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109640] New: Spurious Wdangling-reference for argument to temporary lambda cast to rvalue reference Date: Wed, 26 Apr 2023 23:24:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ed at catmur dot uk X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D109640 Bug ID: 109640 Summary: Spurious Wdangling-reference for argument to temporary lambda cast to rvalue reference Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ed at catmur dot uk Target Milestone: --- bool b() { int a; int&& i =3D [](int& r) -> int&& { return static_cast(r); }(a); auto const l =3D [](int& r) -> int&& { return static_cast(r); }; int&& j =3D l(a); return &i =3D=3D &j; } : In function 'bool b()': :3:11: warning: possibly dangling reference to a temporary [-Wdangling-reference] 3 | int&& i =3D [](int& r) -> int&& { return static_cast(r);= }(a); | ^ :3:68: note: the temporary was destroyed at the end of the full expression 'b()::().b()::(a)' 3 | int&& i =3D [](int& r) -> int&& { return static_cast(r);= }(a); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ^~~ The heuristic appears to be confused by the lambda itself being a temporary, even though it is captureless.=