From: Jakub Jelinek <jakub@redhat.com>
To: Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] warn-access: wrong -Wdangling-pointer with labels [PR106080]
Date: Wed, 15 Feb 2023 10:50:08 +0100 [thread overview]
Message-ID: <Y+yq0JkUKwxibCWC@tucnak> (raw)
In-Reply-To: <20230215034815.1276847-1-polacek@redhat.com>
On Tue, Feb 14, 2023 at 10:48:15PM -0500, Marek Polacek via Gcc-patches wrote:
> -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.
and RESULT_DECL ;)
> Bootstrapped/regtested on ppc64le-pc-linux-gnu, ok for trunk and 12?
>
> 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.
> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/Wdangling-pointer-9.c
> @@ -0,0 +1,9 @@
> +/* PR middle-end/106080 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -Wdangling-pointer" } */
> +
> +void
> +foo (void **failaddr)
> +{
> + *failaddr = ({ __label__ __here; __here: &&__here; });
> +}
Perhaps add dg-bogus above just to make it more clear what
we are testing in the test?
Otherwise LGTM.
Jakub
next prev parent reply other threads:[~2023-02-15 9:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 3:48 Marek Polacek
2023-02-15 9:50 ` Jakub Jelinek [this message]
2023-02-15 13:46 ` [PATCH v2] " Marek Polacek
2023-02-15 13:47 ` Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+yq0JkUKwxibCWC@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=polacek@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).