From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B93363858D38; Tue, 11 Apr 2023 08:25:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B93363858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681201532; bh=/01foxTJjqofMxr8aem8RH5ReNjxO51uulUj0Su0Qyk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NF9uDhmLXgO4sTcr1Wj1nTD5oVHbDuT0LDOeD6T4HTeGSvHbk+47Lu0n96atbjOuC XOMBlgtl2dDOtJTkh3TarEJjkO3FnKEU0lB9vVUoyraEPh7bbECcEAiRzGBazGx52H v/+xH90b0GdC/mkkmaYkV42AWqZnyzTKlogU1LsE= From: "xry111 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109470] unexpected const & behavior Date: Tue, 11 Apr 2023 08:25:32 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xry111 at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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 resolution bug_status 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=3D109470 Xi Ruoyao changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Xi Ruoyao --- The standard says: A temporary object bound to a reference parameter in a function call persis= ts until the completion of the full-expression containing the call. So at the "assert" line the lifetime of the temporary object created by the prvalue to glvalue materialization of (int)lenght has already ended. Any reference to the temporary is dangling and it's undefined behavior to use s= uch a reference.=