https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106394
Tim Lange <tlange at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2022-07-21 Ever confirmed|0 |1 --- Comment #1 from Tim Lange <tlange at gcc dot gnu.org> --- I've noticed earlier that I produced a different behavior for structs and other types, i.e. for struct I check for 'alloc_size >= pointee_size' while for other types I check for 'alloc_size % pointee_size == 0'. I already had it fixed in the first draft patch I sent for PR106181. Long story short, it is a simple fix and regression tests are running. I'll post the fix to the gcc-patches mailing list when the regression tests passed. [...] --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -2956,7 +2956,7 @@ capacity_compatible_with_type (tree cst, tree pointee_size_tree, unsigned HOST_WIDE_INT alloc_size = TREE_INT_CST_LOW (cst); if (is_struct) - return alloc_size >= pointee_size; + return alloc_size == 0 || alloc_size >= pointee_size; return alloc_size % pointee_size == 0; } [...]