https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125072

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Martin Uecker
<[email protected]>:

https://gcc.gnu.org/g:901d06d48225601f12b94f01b7bd2972f068280d

commit r16-9229-g901d06d48225601f12b94f01b7bd2972f068280d
Author: Martin Uecker <[email protected]>
Date:   Thu Jun 4 19:19:33 2026 +0200

    c: wrong code generated with counted_by on pointer + ubsan [PR125072]

    When a pointer is accessed with a constant offset, this has to be split
into
    the size of the element type and the index to be able to instrument the
    index.   The code failed to re-apply the element size after this.

            PR c/125072

    gcc/c-family/ChangeLog:
            * c-ubsan.cc
(get_index_from_offset,get_index_from_pointer_addr_expr,
            is_instrumentable_pointer_array_address): Return factor.
            (ubsan_maybe_instrument_array_ref): Apply factor.

    gcc/testsuite/ChangeLog:
            * gcc.dg/pr125072.c: New test.
            * gcc.dg/ubsan/pointer-counted-by-bounds-124230-union.c: Avoid heap
            corruption.
            * gcc.dg/ubsan/pointer-counted-by-bounds-124230.c: Likewise.

    (cherry picked from commit a02ff0f1faf0858a6fe80492c51b82892ab90479)
  • [Bug c/125072] wrong code gener... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to