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

* [Bug middle-end/100684] spurious -Wnonnull with -O1 on a C++ lambda
  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 ` msebor at gcc dot gnu.org
  2021-05-19 21:03 ` msebor at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-19 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |11.1.0, 12.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |95507
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2021-05-19

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed.  The front end -Wnonull has suppression logic dealing with lambdas
but the middle-end -Wnonnull in tree-ssa-ccp.c doesn't have anything like that.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95507
[Bug 95507] [meta-bug] bogus/missing -Wnonnull

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

* [Bug middle-end/100684] spurious -Wnonnull with -O1 on a C++ lambda
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-19 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
              Build|                            |2021-05-19 0:00
           Keywords|                            |patch
   Target Milestone|---                         |11.2

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570801.html

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

* [Bug middle-end/100684] spurious -Wnonnull with -O1 on a C++ lambda
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-20 19:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:9480491a6447576e8e695b8ea3c4989cf72c9670

commit r12-948-g9480491a6447576e8e695b8ea3c4989cf72c9670
Author: Martin Sebor <msebor@redhat.com>
Date:   Thu May 20 13:15:58 2021 -0600

    PR middle-end/100684 - spurious -Wnonnull with -O1 on a C++ lambda

    gcc/ChangeLog:

            PR middle-end/100684
            * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Handle C++ lambda.

    gcc/testsuite/ChangeLog:

            PR middle-end/100684
            * g++.dg/warn/Wnonnull13.C: New test.
            * g++.dg/warn/Wnonnull14.C: New test.
            * g++.dg/warn/Wnonnull15.C: New test.

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

* [Bug middle-end/100684] [11 Regression] spurious -Wnonnull with -O1 on a C++ lambda
  2021-05-19 15:59 [Bug middle-end/100684] New: spurious -Wnonnull with -O1 on a C++ lambda msebor at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-05-20 19:17 ` cvs-commit at gcc dot gnu.org
@ 2021-05-20 19:19 ` 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
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-20 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|spurious -Wnonnull with -O1 |[11 Regression] spurious
                   |on a C++ lambda             |-Wnonnull with -O1 on a C++
                   |                            |lambda
      Known to fail|12.0                        |

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed on trunk.  Will backport to 11.2.

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

* [Bug middle-end/100684] [11 Regression] spurious -Wnonnull with -O1 on a C++ lambda
  2021-05-19 15:59 [Bug middle-end/100684] New: spurious -Wnonnull with -O1 on a C++ lambda msebor at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-17 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Martin Sebor
<msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:ca0bc927103f5408f4812a3ad65d2d02a37840b2

commit r11-8603-gca0bc927103f5408f4812a3ad65d2d02a37840b2
Author: Martin Sebor <msebor@redhat.com>
Date:   Thu Jun 17 12:01:38 2021 -0600

    PR middle-end/100684 - spurious -Wnonnull with -O1 on a C++ lambda

    gcc/ChangeLog:

            PR middle-end/100684
            * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Handle C++ lambda.

    gcc/testsuite/ChangeLog:

            PR middle-end/100684
            * g++.dg/warn/Wnonnull13.C: New test.
            * g++.dg/warn/Wnonnull14.C: New test.
            * g++.dg/warn/Wnonnull15.C: New test.

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

* [Bug middle-end/100684] [11 Regression] spurious -Wnonnull with -O1 on a C++ lambda
  2021-05-19 15:59 [Bug middle-end/100684] New: spurious -Wnonnull with -O1 on a C++ lambda msebor at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-06-17 20:08 ` cvs-commit at gcc dot gnu.org
@ 2021-06-17 20:10 ` msebor at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-06-17 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Backported to GCC 11.2.

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