public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jlegg at feralinteractive dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/98109] Seemingly wrong warnings from -Wnonnull when combined with -O2 -fsanitize=undefined
Date: Wed, 19 May 2021 10:44:20 +0000	[thread overview]
Message-ID: <bug-98109-4-CZYHQYkBBc@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98109-4@http.gcc.gnu.org/bugzilla/>

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

James Legg <jlegg at feralinteractive dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlegg at feralinteractive dot com

--- Comment #2 from James Legg <jlegg at feralinteractive dot com> ---
The false positives can often be seen when converting a lambda to a function
pointer at lower optimisation levels too. For example, in g++ 11.1.1,
compiling:
int main()
{
        return static_cast<int (*)(int)>([](int x){ return x; })(0);
}

with -Og -Wall -fsanitize=undefined results in:
/tmp/a.cc: In static member function ‘static constexpr int
main()::<lambda(int)>::_FUN(int)’:
/tmp/a.cc:3:63: warning: ‘this’ pointer is null [-Wnonnull]
    3 |         return static_cast<int (*)(int)>([](int x){ return x; })(0);
      |                                                               ^
/tmp/a.cc:3:42: note: in a call to non-static member function
‘main()::<lambda(int)>’
    3 |         return static_cast<int (*)(int)>([](int x){ return x; })(0);
      |                                          ^

  parent reply	other threads:[~2021-05-19 10:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 22:54 [Bug middle-end/98109] New: " gabravier at gmail dot com
2020-12-03  1:08 ` [Bug middle-end/98109] " msebor at gcc dot gnu.org
2021-05-19 10:44 ` jlegg at feralinteractive dot com [this message]
2021-05-19 16:02 ` msebor at gcc dot gnu.org
2022-07-31  9:02 ` b.buschinski at googlemail dot com
2022-08-01 22:01 ` msebor at gcc dot gnu.org

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=bug-98109-4-CZYHQYkBBc@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).