On 2025-06-27 08:39, Siddhesh Poyarekar wrote:
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>
---
Testing notes:
- Local tests continue to look good.
- Bootstraps in progress.
Bootstraps (x86_64 and ubsan config) done, all clear. i686 build and
test clear as well.
Thanks,
Sid