From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A7E843857736; Fri, 8 Mar 2024 14:32:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7E843857736 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709908367; bh=/J9C3yPQH9SGifjYDez0VqZ68k5nxj3vD+Mf2Bt7PY4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TVsUUcs/2wr6lCxOyuE2K4vZADrMjRPrpis7IPgK3VIuUotxBmTaAljPL1kh6+c2M AMZg2kE7yjm3vpkkoP1mQWDkIeSBfNUsRAd6NGCM7nZG7MQWl7S+7nlyVqi0mxPMKS lBI8NUNJpYrfJI88KOaJzAq+/MVyrRRIIwyG8VcQ= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting Date: Fri, 08 Mar 2024 14:32:46 +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: redi at gcc dot gnu.org 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 #9 from Jonathan Wakely --- Ironically, writing a user-provided (and so non-trivial) copy constructor w= hich fixes up the self-referential pointer (or iterator, in your case) will rest= ore guaranteed elision, and that copy constructor isn't actually used. But with a trivial copy constructor, your object gets copied, and the self-referential pointer gets invalidated because it points to a temporary = that has gone out of scope, not to the final object after the copies are done.=