https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112716
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: gcc -flto -O2 y.c y2.c -DT1="int[n]" -DT2="int[n]" // y.c void bar(void*); [[gnu::noinline,gnu::noipa]] int foo(void *p, void *q) { int n = 5; struct foo { int x; typeof(T1) y; } *p2 = p; p2->x = 1; bar(q); return p2->x; } int main() { int n = 5; void *p = __builtin_malloc(sizeof(struct foo { int x; typeof(T1) y; })); if (!p) return 0; if (2 != foo(p, p)) __builtin_abort(); return 0; } // y2 void bar(void* q) { int n = 5; struct foo { int x; typeof(T2) y; } *q2 = q; q2->x = 2; }