Hi! This testcase got fixed in r257155 aka PR83942, but unlike the PR83942 testcase which regressed during 8.x stage1 this one used to fail before too, so I think it is worth adding another testcase for it.
Tested on x86_64-linux, committed to trunk as obvious. 2018-02-20 Jakub Jelinek <ja...@redhat.com> PR c++/84488 * g++.dg/warn/Wunused-var-30.C: New test. --- gcc/testsuite/g++.dg/warn/Wunused-var-30.C.jj 2018-02-20 17:53:26.539480455 +0100 +++ gcc/testsuite/g++.dg/warn/Wunused-var-30.C 2018-02-20 17:53:18.419481675 +0100 @@ -0,0 +1,11 @@ +// PR c++/84488 +// { dg-do compile } +// { dg-options "-Wunused-but-set-variable" } + +int +foo () +{ + enum E { A, B, C, D }; + double r = 1.0; // { dg-bogus "set but not used" } + return static_cast<E>(r); +} Jakub