From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 944103858C5E; Fri, 11 Aug 2023 20:35:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 944103858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691786112; bh=1nzFUtbBPbiVB/joAUZaemzTIH4GFsmB7CANVCw6yok=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Codgsint4dLNTi2nguxNzQJjFWw99R1nvMDeLX5Xsqa+CsthkG/i8P0FblkboOzhw I7hIEv8twtM8ITmIBae+pS6nIXGdOBe1m4RCDDYr/vHPdcCIP45dAPKgzNAEQDa9+A jq35RMOll/dUOJ8RJB4gKUagS+1+25vj6aT1UD/Y= From: "jason at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/81420] When a reference is bound to a member in the base of a temporary, lifetime of the temporary is not extended Date: Fri, 11 Aug 2023 20:35:11 +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: 8.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jason at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jason at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution target_milestone 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=3D81420 Jason Merrill changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED Target Milestone|--- |8.2 --- Comment #8 from Jason Merrill --- (In reply to Ion Lupascu from comment #7) > Not really, The issue still persists >=20 > std::optional getValue(){ ... > const double &v =3D *getValue(); ... > const double &v =3D getValue()->v; Neither of these bind the reference to a prvalue; std::optional operator* returns a reference, and operator-> returns a pointer, so in both cases we'= re binding the reference to an xvalue, and GCC is correct not to extend the temporary. Fixed in 8.2.=