Hi, Reduced testcase (automatically; it might be possible to reduce further): enum a { b }; struct c { template < a > int d() { const bool is_ident = 0; const int ret = is_ident ? 7 : 9; return ret; } void e() { d < b > (); } }; When compiled with -Wall, yields: test.cc: In instantiation of 'int c::d() [with a <anonymous> = (a)0]': test.cc:9:12: required from here test.cc:4:14: warning: variable 'is_ident' set but not used [-Wunused-but-set-variable] const bool is_ident = 0; ^~~~~~~~ even though is_ident is clearly used on the line below. gcc version 8.0.0 20171017 (experimental) [trunk revision 253812] (Debian 20171017-1) This does not happen with GCC 7.2.1.
Started with r253266.
Looks like a dup of PR82728.
Indeed, let's do it, but make sure we have both testcases in the testsuite after the fix. *** This bug has been marked as a duplicate of bug 82728 ***
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