From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 707123899084; Fri, 21 Jun 2024 13:48:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 707123899084 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718977733; bh=JeAtj7sI/esoviycq4SmTfkeahXVZf8nnFD+zk2blOg=; h=From:To:Subject:Date:From; b=bBXW47kpK/OpuTQ5eCvtrUSbKhpeY94N1u906fkV+czBRr8y+x9B44SGvLQbxUSyN s/kcTJvE4L9Fg+5ota12MLrThayEv/6S/ob/s5hG0um2pAbW+9UaSqfsoYZTAJPSlL hQk5JPvynj05g7LCsxN0Dn7YIXRLK66fEvw/ceDU= From: "tangyixuan at mail dot dlut.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115582] New: [regression 15] wrong code when accessing members of incompatible type structure Date: Fri, 21 Jun 2024 13:48:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tangyixuan at mail dot dlut.edu.cn 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D115582 Bug ID: 115582 Summary: [regression 15] wrong code when accessing members of incompatible type structure Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tangyixuan at mail dot dlut.edu.cn Target Milestone: --- Hi, I find GCC produces wrong code under optimizations when pointers point = to incompatible type structure but the member types are compatible. Compiler Explorer: https://godbolt.org/z/jjY599Yfe $ cat s.c int printf(const char *, ...); struct s {int x; } __attribute__((packed)); struct t {int x; }; void swap(struct s* p, struct t* q) { p->x =3D q->x; q->x =3D p->x; } int main() {=20=20=20=20 struct t a[2]; a[0].x =3D 1234; a[1].x =3D 5678; swap ((struct s *)((char *)a + 1), a); printf("%d",a[0].x); return 0; }=