From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 33B8E385843A; Thu, 25 Jan 2024 23:09:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33B8E385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706224160; bh=PIWMXvtydGUXJyF793x5ibp/GfT9b16yp2+Im2OZYAA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ogLJz0L+78/iArebus9+a7lyLh6zFvdvpzU+ipzBOLV1ukGeJCpMHRfb4lJxqeNlU zUFssfzUjaPT4M/DLPTmeqFxJh8XwF+LsqSdEkxPB379Ay4w+RgDxDUBD4ZdT7b23Y O9xarvsdV4j7hdoCbk9LOkAMO4bxZcl3VfElDeYM= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113599] [14 Regression] Wrong computation of member offset through pointer-to-member since r14-5503 Date: Thu, 25 Jan 2024 23:09:17 +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: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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=3D113599 --- Comment #6 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:fd620bd3351c6b9821c299035ed17e655d7954b5 commit r14-8439-gfd620bd3351c6b9821c299035ed17e655d7954b5 Author: Jakub Jelinek Date: Fri Jan 26 00:08:36 2024 +0100 c++: Fix up build_m_component_ref [PR113599] The following testcase reduced from GDB is miscompiled starting with r14-5503 PR112427 change. The problem is in the build_m_component_ref hunk, which changed - datum =3D fold_build_pointer_plus (fold_convert (ptype, datum), component); + datum =3D cp_convert (ptype, datum, complain); + if (!processing_template_decl) + datum =3D build2 (POINTER_PLUS_EXPR, ptype, + datum, convert_to_ptrofftype (component)); + datum =3D cp_fully_fold (datum); Component is e, (sizetype) e is 16, offset of c inside of C. ptype is A *, pointer to type of C::c and datum is &d. Now, previously the above created ((A *) &d) p+ (sizetype) e which is correct, but in the new code cp_convert sees that C has A as base class and instead of returning (A *) &d, it returns &d.D.2800 where D.2800 is the FIELD_DECL for the A base at offset 8 into C. So, instead of computing ((A *) &d) p+ (sizetype) e it computes &d.D.2800 p+ (sizetype) e, which is ((A *) &d) p+ 24. The following patch fixes it by using convert instead of cp_convert whi= ch eventually calls build_nop (ptype, datum). 2024-01-26 Jakub Jelinek PR c++/113599 * typeck2.cc (build_m_component_ref): Use convert instead of cp_convert for pointer conversion. * g++.dg/expr/ptrmem11.C: New test.=