From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8AE163856DD0; Tue, 15 Aug 2023 14:53:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AE163856DD0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692111189; bh=sdRSvO4Wl1GpTPj/ze2ouWPGTBr7ucG2lZPwVxAoqK4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EFStimgMMJchZ4iNunSaSKJFrzSuDwCMdCXhUvq3zqI/NbJuU6nag4Z+b9stJdmyR UBL8Dv9ClcuQWMtdga8226aNKUtFrRe597H9LTrY4ZpG1qhLGN3iXYp9CGoL4Ks4+q +7/DIPK1SaS2cEm3PYSmjPO/BpuMd9cEgpNCYNkE= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111028] Incorrect optimization with -o1,-o2 Date: Tue, 15 Aug 2023 14:53:09 +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: 12.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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=3D111028 --- Comment #4 from Patrick Palka --- Or simply just: diff --git a/111028.C b/111028.C index ed4106e..85f1c2a 100644 --- a/111028.C +++ b/111028.C @@ -15,7 +15,7 @@ class list_t public: list_t() { _head.next =3D _head.prev =3D &_head; } bool is_empty() const { return _head.next =3D=3D &_head; } - T* entry(list_node_t &node) const { return &node =3D=3D &_h= ead ? NULL : (T*)((char*)&node - (char*)_node_offset); } + T* entry(list_node_t &node) const { return &node =3D=3D &_h= ead ? NULL : (T*)((char*)&node - (size_t)_node_offset); } void add(T &node) {=