On 2025-06-27 07:40, 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>
---

Sorry, forgot to mention testing:

* bootstrapped on x86_64, no new failures spotted
* built and tested i686, no new failures
* bootstrapped with --with-build-config=bootstrap-ubsan

Thanks,
Sid

Reply via email to