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

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

https://gcc.gnu.org/g:e80faace7e7fdfc33719c1759a609937321298ee

commit r17-6858-ge80faace7e7fdfc33719c1759a609937321298ee
Author: Oleg Tolmatcev <[email protected]>
Date:   Mon Nov 30 16:09:21 2026 -0700

    [PATCH v2] c: Mark a counted_by member read through .ACCESS_WITH_SIZE
[PR127932]

    A read of a member with the counted_by attribute is wrapped in a call
    to .ACCESS_WITH_SIZE, and for a flexible array member the call is
    wrapped in an INDIRECT_REF.  mark_exp_read looked into neither, so the
    structure the member was read from was never marked as read, and
    -Wunused-but-set-parameter and -Wunused-but-set-variable warned about
    a parameter or variable that was used.

    ---

     gcc/c/c-typeck.cc                             |  8 +++
     .../gcc.dg/pointer-counted-by-pr127932.c      | 55 +++++++++++++++++++
     2 files changed, 63 insertions(+)
     create mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-pr127932.c

    v2: fixed an issue found by Sashiko

    I don't have write access. Regtested on Linux x86-64.

            PR c/127932

    gcc/c/ChangeLog:

            * c-typeck.cc (mark_exp_read): Handle a call to
            .ACCESS_WITH_SIZE, and an INDIRECT_REF of one, by marking its
            reference as read.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pointer-counted-by-pr127932.c: New test.

    Signed-off-by: Oleg Tolmatcev <[email protected]>

Reply via email to