From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C97C3393BC27; Wed, 19 May 2021 15:59:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C97C3393BC27 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/100684] New: spurious -Wnonnull with -O1 on a C++ lambda Date: Wed, 19 May 2021 15:59:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 15:59:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100684 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 funct= ion > pointer at lower optimisation levels too. For example, in g++ 11.1.1, > compiling: > int main() > { > return static_cast([](int x){ return x; })(0); > } >=20 > with -Og -Wall -fsanitize=3Dundefined results in: > /tmp/a.cc: In static member function =E2=80=98static constexpr int > main()::::_FUN(int)=E2=80=99: > /tmp/a.cc:3:63: warning: =E2=80=98this=E2=80=99 pointer is null [-Wnonnul= l] > 3 | return static_cast([](int x){ return x; })(= 0); > | ^ > /tmp/a.cc:3:42: note: in a call to non-static member function > =E2=80=98main()::=E2=80=99 > 3 | return static_cast([](int x){ return x; })(= 0); > | ^=