https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122348
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <[email protected]>: https://gcc.gnu.org/g:9077e2067bc8667084745c7746b48d0e3e49b063 commit r16-7030-g9077e2067bc8667084745c7746b48d0e3e49b063 Author: Roger Sayle <[email protected]> Date: Sun Jan 25 21:06:39 2026 +0000 PR middle-end/122348: ICE in store_constructor from flexible array member This patch resolves PR middle-end/122348, an ICE caused by passing a initialized structure containing a flexible array member by value. The semantics in C99 (and since gcc 4.4) are that the zero sized array at the end of the structure is ignored when passing by value. Hence for the structure in the PR: struct S { int a; int b[]; } s = { 0, { 42 } }; when passed by value, sizeof(s) is considered to be 4 bytes, and on x86_64 passed in the 32-bit %edi register. Unfortunately, the code in store_constructor isn't expecting initialized fields where the type's DECL_SIZE is NULL, which leads to the ICE. Fixed by explicitly ignoring fields where DECL_SIZE is NULL_TREE. On x86_64, passing "s" now compiles to just: f: xorl %edi, %edi jmp foo 2026-01-25 Roger Sayle <[email protected]> gcc/ChangeLog PR middle-end/122348 * expr.cc (store_constructor): Ignore fields where DECL_SIZE is NULL_TREE, i.e. flexible array members. gcc/testsuite/ChangeLog PR middle-end/122348 * g++.dg/pr122348.C: New C++ testcase. * gcc.dg/pr122348.c: New C testcase.
