On 20/06/2022 15:20, Jakub Jelinek wrote:
On Tue, Jun 14, 2022 at 09:01:54PM +0530, Siddhesh Poyarekar wrote:
The addr_expr computation does not check for error_mark_node before
returning the size expression.  This used to work in the constant case
because the conversion to uhwi would end up causing it to return
size_unknown, but that won't work for the dynamic case.

Regarding subject/first line of commit, it should be something like:

tree-object-size: Don't let error_mark_node escape for ADDR_EXPR [PR105736]
instead of what you have.

Modify the control flow to explicitly return size_unknown if the offset
computation returns an error_mark_node.

gcc/ChangeLog:

        PR tree-optimization/105736
        * tree-object-size.cc (addr_object_size): Return size_unknown
        when object offset computation returns an error.

gcc/testsuite/ChangeLog:

        PR tree-optimization/105736
        * gcc.dg/builtin-dynamic-object-size-0.c (TV4, val3,
        test_pr105736): New struct declaration, variable and function to
        test PR.

If you want to spell the exact changes in the test, it would be better
to do it separately when it is different changes.

Thanks, fixed up before pushing to master.

        * gcc.dg/builtin-dynamic-object-size-0.c (struct TV4): New type.
        (val3): New variable.
        (test_pr105736): New function.
        (main): Use them.

Otherwise LGTM, but for GCC 13, it would be nice to add support
for BIT_FIELD_REF if both second and third arguments are multiples of
BITS_PER_UNIT.

Ack, I'll test and post this as a separate change.

Signed-off-by: Siddhesh Poyarekar <siddh...@gotplt.org>
---
Changes from v1:
- Used FAIL() instead of __builtin_abort() in the test.

Tested:

- x86_64 bootstrap and test
- --with-build-config=bootstrap-ubsan build

May I also backport this to gcc12?

Ok.

Thanks, I'll give it a couple of days in master and then cherry-pick.

Sid

Reply via email to