https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120780
--- Comment #19 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Siddhesh Poyarekar <siddh...@gcc.gnu.org>: https://gcc.gnu.org/g:72e85d46472716e670cbe6e967109473b8d12d38 commit r16-1972-g72e85d46472716e670cbe6e967109473b8d12d38 Author: Siddhesh Poyarekar <siddh...@gotplt.org> Date: Thu Jun 26 17:46:00 2025 -0400 tree-optimization/120780: Support object size for containing objects MEM_REF cast of a subobject to its containing object has negative offsets, which objsz sees as an invalid access. Support this use case by peeking into the structure to validate that the containing object indeed contains a type of the subobject at that offset and if present, adjust the wholesize for the object to allow the negative offset. gcc/ChangeLog: PR tree-optimization/120780 * tree-object-size.cc (inner_at_offset, get_wholesize_for_memref): New functions. (addr_object_size): Call get_wholesize_for_memref. gcc/testsuite/ChangeLog: PR tree-optimization/120780 * gcc.dg/builtin-dynamic-object-size-pr120780.c: New test case. Signed-off-by: Siddhesh Poyarekar <siddh...@gotplt.org>