From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 012103858CD1; Sun, 26 Nov 2023 17:46:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 012103858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701020814; bh=NdEhC6vMDLbOlFBDQPWxZJUX/IX3Fu0jt6CUF48Dbsk=; h=From:To:Subject:Date:From; b=KdUAFPyjG6Qk2mF4mRVNkasGH5b+0PA8THroait+A9AwFgSnFAX9+f623gbol5/fL GIxjHwSDBy52Dt86DIPggPZFiPRW+sFNe0X2CmKHVp/IP6uydJfwlhFWxfE25ffxvK VfhFQ3vj+wc5QyMzRMoH36OdGwCmHEEquv3KVmEw= From: "muecker at gwdg dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/112716] New: LTO optimization with struct of variable ssize Date: Sun, 26 Nov 2023 17:46:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: muecker at gwdg dot de 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 cc 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=3D112716 Bug ID: 112716 Summary: LTO optimization with struct of variable ssize Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: muecker at gwdg dot de CC: marxin at gcc dot gnu.org Target Milestone: --- The following code using a GNU extension gets miscompiled due to incorrect aliasing assumptions with -flto and -O2:=20 gcc -flto -O2 y.c y2.c -DT1=3D"int[n]" -DT2=3D"int[n]" // y.c void bar(void*); [[gnu::noinline,gnu::noipa]] int foo(void *p, void *q) { int n =3D 5; struct foo { int x; typeof(T1) y; } *p2 =3D p; p2->x =3D 1; bar(q); return p2->x; } int main() { int n =3D 5; void *p =3D __builtin_malloc(sizeof(struct foo { int x; typeof(T1) = y; })); if (!p) return 0; if (2 !=3D foo(p, p)) __builtin_abort(); return 0; } // y2 void bar(void* q) {=20=20=20=20=20=20=20 int n =3D 5; struct foo { int x; typeof(T2) y; } *q2 =3D q; q2->x =3D 2; }=