public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/100684] New: spurious -Wnonnull with -O1 on a C++ lambda
@ 2021-05-19 15:59 msebor at gcc dot gnu.org
  2021-05-19 16:01 ` [Bug middle-end/100684] " msebor at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-19 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100684
           Summary: spurious -Wnonnull with -O1 on a C++ lambda
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

>From James Legg in comment pr98109 comment 2:

> 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);
>       |                                          ^

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-17 20:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 15:59 [Bug middle-end/100684] New: spurious -Wnonnull with -O1 on a C++ lambda msebor at gcc dot gnu.org
2021-05-19 16:01 ` [Bug middle-end/100684] " msebor at gcc dot gnu.org
2021-05-19 21:03 ` msebor at gcc dot gnu.org
2021-05-20 19:17 ` cvs-commit at gcc dot gnu.org
2021-05-20 19:19 ` [Bug middle-end/100684] [11 Regression] " msebor at gcc dot gnu.org
2021-06-17 20:08 ` cvs-commit at gcc dot gnu.org
2021-06-17 20:10 ` msebor at gcc dot gnu.org

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).