public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Gallager <egall@gwmail.gwu.edu>
To: Martin Sebor <msebor@gmail.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
	Jason Merrill <jason@redhat.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] restore ancient -Waddress for weak symbols [PR33925]
Date: Mon, 4 Oct 2021 18:39:52 -0400	[thread overview]
Message-ID: <CAMfHzOvuNXdfOfOTKDZXZv-MnaSHMh3xvFkGaYNkib1N99Kpnw@mail.gmail.com> (raw)
In-Reply-To: <679cf10f-e16a-e318-0e82-820efb109d0f@gmail.com>

On Mon, Oct 4, 2021 at 2:43 PM Martin Sebor via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> While resolving the recent -Waddress enhancement request (PR
> PR102103) I came across a 2007 problem report about GCC 4 having
> stopped warning for using the address of inline functions in
> equality comparisons with null.  With inline functions being
> commonplace in C++ this seems like an important use case for
> the warning.
>
> The change that resulted in suppressing the warning in these
> cases was introduced inadvertently in a fix for PR 22252.
>
> To restore the warning, the attached patch enhances
> the decl_with_nonnull_addr_p() function to return true also for
> weak symbols for which a definition has been provided.
>
> Tested on x86_64-linux and by comparing the GCC output for new
> test cases to Clang's which diagnoses all but one instance of
> these cases with either -Wtautological-pointer-compare or
> -Wpointer-bool-conversion, depending on context.

Would it make sense to use the same names as clang's flags here, too,
instead of dumping them all under -Waddress? I think the additional
granularity could be helpful for people who only want some warnings,
but not others.

> The one case where Clang doesn't issue a warning but GCC
> with the patch does is for a symbol explicitly declared with
> attribute weak for which a definition has been provided.
> I believe the address of such symbols is necessarily nonnull and
> so issuing the warning is helpful
> (both GCC and Clang fold such comparisons to a constant).
>
> Martin

  parent reply	other threads:[~2021-10-04 22:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 18:42 Martin Sebor
2021-10-04 21:37 ` Jason Merrill
2021-10-23 23:06   ` Martin Sebor
2021-11-07 23:31     ` PING " Martin Sebor
2021-11-15 16:50       ` PING 2 " Martin Sebor
2021-11-16 20:23     ` Jason Merrill
2021-11-17  1:11       ` Martin Sebor
2021-11-17 18:31         ` Jason Merrill
2021-11-17 19:21           ` Martin Sebor
2021-11-18  1:27             ` Martin Sebor
2021-11-18 15:58               ` Jason Merrill
2021-10-04 22:39 ` Eric Gallager [this message]
2021-11-02 18:51   ` Martin Sebor
2021-11-02 19:28     ` Marek Polacek

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=CAMfHzOvuNXdfOfOTKDZXZv-MnaSHMh3xvFkGaYNkib1N99Kpnw@mail.gmail.com \
    --to=egall@gwmail.gwu.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=msebor@gmail.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).