https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82799

            Bug ID: 82799
           Summary: [8 Regression] -Wunused-but-set-variable false
                    positive
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sgunderson at bigfoot dot com
  Target Milestone: ---

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.

Reply via email to