From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 497313858D38; Tue, 11 Apr 2023 10:37:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 497313858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681209427; bh=/9EKFOJiKoiV00z6MR2H0HNolx+FN5nIQOfEeFC6g34=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IXX3Bm0GSZERKTkUMqrDZXCsTEArpCrZ4Hm3kCXjbuvOzVUycwzlsI6m/i6BwsQDn EJK0u+Wdo6maopzaLAXPMRflwObDXpI+whNAAjBmXqRWaGlGqMzr4Mc8iVvmJZBHJJ fG/kY4Gp1fzIA2SQuL4NYawpGWP7Jt3rLTwHng5s= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109470] unexpected const & behavior Date: Tue, 11 Apr 2023 10:37:06 +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: redi 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: 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 --- Comment #8 from Jonathan Wakely --- No, "full-expression" is a formal term defined very precisely in the C++ standard. There is no opportunity for GCC to review that without failing to conform to the C++ standard. Changing when temporary objects are destroyed would be a massive breaking change to the C++ language that would break assumptions made by correct code. Just because you don't get a warning with other compilers, doesn't mean your code is correct. The code accesses an object outside its lifetime, and so h= as undefined behaviour. That is true with all compilers. Clang gives a runtime error with -fsanitize=3Daddress e.g. https://godbolt.org/z/dhcEhvzze That's because the program has undefined behaviour. This is not just GCC's interpretation of the C++ standard, it's a fact.=