From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0AF3A3857B8D; Fri, 23 Sep 2022 15:03:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AF3A3857B8D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663945432; bh=gc89j75aQHCsGkflxokytrGDX1j8SkD8haHCbN+DuA8=; h=From:To:Subject:Date:From; b=sJM8Mwc9FmXKZ+wF/1gblX0VPh1tJaLnpB1hjUUnAbmoTJ2gBDC9uFdyO01xgzO80 SMqt8RsIb24sdFipTMzS32mmp0MWOzaKd1D6QGpdBa1xb5amDLa6kn0zyLJ6LXKH/Y qk5eS1qy6EEcLAwkmhL9vFnqAzYdJyqgpvDPMO0Y= From: "mario at klebsch dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107019] New: -Wunused-but-set-variable false positive for static variable in lambda with boost Date: Fri, 23 Sep 2022 15:03:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mario at klebsch dot de 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107019 Bug ID: 107019 Summary: -Wunused-but-set-variable false positive for static variable in lambda with boost Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mario at klebsch dot de Target Milestone: --- I get a palse positive from -Wunused-but-set-variable with this little samp= le: #include #include int main(int argc, char *argv[]) { static const char *func =3D __FUNCTION__; boost::asio::io_service io_service; boost::asio::deadline_timer timer(io_service); timer.async_wait( [](auto) { printf("%s()\n", func); }); } ~/tmp $ g++ -Wall bug2.cpp -c -I boost_1_80_0/ bug2.cpp: In function =E2=80=98int main(int, char**)=E2=80=99: bug2.cpp:7:28: warning: variable =E2=80=98func=E2=80=99 set but not used [-Wunused-but-set-variable] 7 | static const char *func =3D __FUNCTION__; | ^~~~ ~/tmp $ If I do not call timer.async_wait() but some other function taking const std::function& as parameter, the us= age of func in the lambda is recognized correctly. 73, Mario=