This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81299] Spurious "set but not used" warning with constexpr variable
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Jul 2017 13:13:43 +0000
- Subject: [Bug c++/81299] Spurious "set but not used" warning with constexpr variable
- Auto-submitted: auto-generated
- References: <bug-81299-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81299
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If fun is just const and not constexpr, then we mark it TREE_USED during
build_capture_proxy, if it is not const nor constexpr, then when force_rvalue
in build_lambda_capture. But when it is constexpr, it goes through none of
that. Not sure what to do, for constexpr vars the -Wunused-but-set-variable
warning doesn't make much sense, one can't set them except for the initializer,
and so either the var is unused except for the declaration with the
initializer, then we should emit normal -Wuninitialized warning, or it is not
unused, then we just shouldn't warn.