https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126975
--- Comment #8 from Gustavo A. R. Silva <gustavo at embeddedor dot com> --- I submitted v2 for this patch: https://gcc.gnu.org/pipermail/gcc-patches/2026-September/729904.html The fix now applies under -fstrict-flex-arrays=3 only. (I personally think it should apply unconditionally, but it's fine to be conservative in this case, as the Linux kernel is built under -fstrict-flex-arrays=3 as well.) So, considering: struct flex { size_t count; char fam[]; }; /* sizeof(struct flex) == 8 */ struct outer { int hdr; struct flex inner; }; struct outer *p = __builtin_malloc (sizeof (*p) + 48); /* 64-byte object */ See below for a comparison of v2 vs unpatched trunk for __builtin_object_size/__builtin_dynamic_object_size(&p->inner, 1) across -fstrict-flex-arrays levels: -fstrict-flex-arrays= v2 Unpatched Effect --------------------- -- --------- ------ default (0)/1/2 56 56 Unchanged (type-1 size == type-0 size) 3 8 56 Fix fires (measures the subobject) Thanks :)
