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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:8af44715f731f9838a917089305d7c5f35036a79

commit r16-8796-g8af44715f731f9838a917089305d7c5f35036a79
Author: Jakub Jelinek <[email protected]>
Date:   Wed Apr 22 07:54:27 2026 +0200

    c: Fix counted_by attribute error recovery [PR124969]

    The last patch made me try also pointer arithmetics on incomplete
    type.  And here we ICE before actually diagnosing the error
    because we try to dereference element_size.

    Furthermore, TYPE_SIZE_UNIT (element_type) is in sizetype, so
    we shouldn't use build_one_cst (size_type_node) for the void *
    case, but size_one_node (aka size_int (1)).

    2026-04-22  Jakub Jelinek  <[email protected]>

            PR sanitizer/124969
            * c-typeck.cc (build_access_with_size_for_counted_by): Use
            size_one_node instead of build_one_cst (size_type_node).  Punt
            if element_size is NULL_TREE.

            * gcc.dg/ubsan/pr124969-2.c: New test.

    Reviewed-by: Marek Polacek <[email protected]>

Reply via email to