From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 26E5F385B50E; Fri, 8 Mar 2024 12:59:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26E5F385B50E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709902740; bh=e3xEvjADj1JSTslWrAXDybUm5G3JFQYAnJdd9ZXWxPk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Gxmm91MKEIcPVO2Buca7rxjqxSU7swFBfcCmp7DZ+lpvgdiOBt1lC0AZprVvQVsSq qaMW6BsCGIjK6NkEiFd7CotMQ+Ong9e79vQ0ESd4yOydCZI3FzXYznsxHjHcMqCXWb H4PEza2nA7reDP0TyV7NMFgRZNTJxGBoCvB8IBd0= From: "raffael at casagrande dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting Date: Fri, 08 Mar 2024 12:58:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: needs-reduction, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: raffael at casagrande dot ch 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: 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=3D112307 --- Comment #7 from Raffael Casagrande --- @Jonathan Wakely Thanks very much for the detailed analysis. But there is o= ne point which I don't understand: > BUT, the self-referential pointer is set to the address of the range_ mem= ber=20 > before the return value is copied, and so goes out of scope when that obj= ect > is copied via registers and then copied again into the automatic variable > in main(). I can't follow/understand how Next() is called before the return value is copied. If we look at the constructor of EnumeratorRange, we see that `enumerator_`= is initialized before end_reached_. And afterwards the enumerator_ is not moved/copied anymore because of copy elision? This can be verified by adding some extra print statements to the copy/move constructor of Enumerator.=