public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/96400] New: False positive on Wunused-but-set-variable for static constexpr var used in lambda @ 2020-07-31 9:56 gccbugbjorn at fahller dot se 2021-07-27 4:49 ` [Bug c++/96400] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: gccbugbjorn at fahller dot se @ 2020-07-31 9:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96400 Bug ID: 96400 Summary: False positive on Wunused-but-set-variable for static constexpr var used in lambda Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gccbugbjorn at fahller dot se Target Milestone: --- Similar to Bug 96311, but not quite the same. This code is flags "is_zero" as being unused but set: template <typename Pred, typename Val> bool test(Pred p, Val v) { return p(v); } bool func(int* p) { static constexpr auto is_zero = [](auto v) { return v == 0;}; return test([](auto v){return is_zero(*v);}, p); } Output: <source>: In function 'bool func(int*)': <source>:9:27: warning: variable 'is_zero' set but not used [-Wunused-but-set-variable] 9 | static constexpr auto is_zero = [](auto v) { return v == 0;}; | ^~~~~~~ "is_zero" can correctly be used in the lambda without being captured, since it's static. The warning only appears when using the extra indirection "test()". Calling the anonymous lambda directly, without the indirection "test()", does not display the warning. Possibly "constexpr" is a red herring above. Godbolt link: https://godbolt.org/z/x4zb3s ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96400] False positive on Wunused-but-set-variable for static constexpr var used in lambda 2020-07-31 9:56 [Bug c++/96400] New: False positive on Wunused-but-set-variable for static constexpr var used in lambda gccbugbjorn at fahller dot se @ 2021-07-27 4:49 ` pinskia at gcc dot gnu.org 2022-09-23 16:16 ` pinskia at gcc dot gnu.org 2022-09-23 16:27 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-07-27 4:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96400 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2021-07-27 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Here is the most reduced C++20 testcase which produce the warning: void test(auto){} void func() { static auto is_zero = [](){ }; test([](auto v){return is_zero(*v);}); } Here is a C++17 testcase: template<typename t> void test(t){} void func() { static auto is_zero = [](){ }; test([](auto v){return is_zero(*v);}); } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96400] False positive on Wunused-but-set-variable for static constexpr var used in lambda 2020-07-31 9:56 [Bug c++/96400] New: False positive on Wunused-but-set-variable for static constexpr var used in lambda gccbugbjorn at fahller dot se 2021-07-27 4:49 ` [Bug c++/96400] " pinskia at gcc dot gnu.org @ 2022-09-23 16:16 ` pinskia at gcc dot gnu.org 2022-09-23 16:27 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-09-23 16:16 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96400 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |johelegp at gmail dot com --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 105743 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96400] False positive on Wunused-but-set-variable for static constexpr var used in lambda 2020-07-31 9:56 [Bug c++/96400] New: False positive on Wunused-but-set-variable for static constexpr var used in lambda gccbugbjorn at fahller dot se 2021-07-27 4:49 ` [Bug c++/96400] " pinskia at gcc dot gnu.org 2022-09-23 16:16 ` pinskia at gcc dot gnu.org @ 2022-09-23 16:27 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-09-23 16:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96400 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Changing "[](auto v)" to "[](int *v)" removes the warning. So this is a dup of bug 88804. *** This bug has been marked as a duplicate of bug 88804 *** ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-23 16:27 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-07-31 9:56 [Bug c++/96400] New: False positive on Wunused-but-set-variable for static constexpr var used in lambda gccbugbjorn at fahller dot se 2021-07-27 4:49 ` [Bug c++/96400] " pinskia at gcc dot gnu.org 2022-09-23 16:16 ` pinskia at gcc dot gnu.org 2022-09-23 16:27 ` pinskia 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).