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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Marek Polacek
<mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:825a47f1bb9a42df65157d4dc0a11b2c054e97cc

commit r12-9176-g825a47f1bb9a42df65157d4dc0a11b2c054e97cc
Author: Marek Polacek <pola...@redhat.com>
Date:   Tue Feb 14 17:05:44 2023 -0500

    warn-access: wrong -Wdangling-pointer with labels [PR106080]

    -Wdangling-pointer warns when the address of a label escapes.  This
    causes grief in OCaml (<https://github.com/ocaml/ocaml/issues/11358>) as
    well as in the kernel:
    <https://bugzilla.kernel.org/show_bug.cgi?id=215851> because it uses

      #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here;
})

    to get the PC.  -Wdangling-pointer is documented to warn about pointers
    to objects.  However, it uses is_auto_decl which checks DECL_P, but DECL_P
    is also true for a label/enumerator/function declaration, none of which is
    an object.  Rather, it should use auto_var_p which correctly checks VAR_P
    and PARM_DECL.

            PR middle-end/106080

    gcc/ChangeLog:

            * gimple-ssa-warn-access.cc (is_auto_decl): Remove.  Use auto_var_p
            instead.

    gcc/testsuite/ChangeLog:

            * c-c++-common/Wdangling-pointer-10.c: New test.
            * c-c++-common/Wdangling-pointer-9.c: New test.

    (cherry picked from commit d482b20fd346482635a770281a164a09d608b058)

Reply via email to