https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92088
Bug ID: 92088 Summary: aggregates with VLAs and nested functions are broken Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- Tried to see where we might miscompile things due to the inliner remapping types... void foo(int n) { struct X { int a[n]; } y; struct X baz (struct X x) { x.a[0] = 1; return x; } y.a[0] = 0; y = baz(y); if (y.a[0] != 1) __builtin_abort (); } ICEs left and right. After fixing the most obvious we end up with t.c: In function ‘foo’: t.c:1:6: error: size of variable ‘x’ is too large 1 | void foo(int n) | ^~~ when inlining because the inliner fails to appropriately "allocate" the parameter space for baz 'x': foo (int n) { struct X x; struct X * y.1; sizetype _1; int _7; sizetype _8; <bb 2> [local count: 1073741824]: __builtin_dwarf_cfa (0); _1 = (sizetype) n_2(D); _8 = _1 * 4; y.1_10 = __builtin_alloca_with_align (_8, 32); y.1_10->a[0] = 0; x = [with_size_expr] WITH_SIZE_EXPR <*y.1_10, _8>; x.a[0] = 1; __builtin_memcpy (y.1_10, &x, _8); x ={v} {CLOBBER}; _7 = y.1_10->a[0];