As of gcc version 8.0.0 20180102 (experimental) (GCC) gcc gives an unused-but-set warning for variables that are used only in a static_assert. For example, with this source: --- x.cc ------------------------------------- void foo() { constexpr bool foo = true; static_assert(foo, "foo"); } ---------------------------------------------- we get a warning: $ cc1plus -std=c++17 x.cc -quiet -Wall x.cc: In function ‘void foo()’: x.cc:3:18: warning: variable ‘foo’ set but not used [-Wunused-but-set-variable] constexpr bool foo = true; ^~~ We do not get this warning with gcc 7.2.1.
Started with r253266. Jason?
Created attachment 43046 [details] gcc8-pr83690.patch This does seem to do the job.
Author: jason Date: Thu Jan 11 19:08:41 2018 New Revision: 256550 URL: https://gcc.gnu.org/viewcvs?rev=256550&root=gcc&view=rev Log: PR c++/82728 - wrong -Wunused-but-set-variable PR c++/82799 PR c++/83690 * call.c (perform_implicit_conversion_flags): Call mark_rvalue_use. * decl.c (case_conversion): Likewise. * semantics.c (finish_static_assert): Call perform_implicit_conversion_flags. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-switch2.C trunk/gcc/testsuite/g++.dg/warn/Wunused-var-27.C trunk/gcc/testsuite/g++.dg/warn/Wunused-var-28.C trunk/gcc/testsuite/g++.dg/warn/Wunused-var-29.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/decl.c trunk/gcc/cp/semantics.c
Fixed.