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

            Bug ID: 105208
           Summary: incorrect -Wunused-but-set-variable for static const
                    variables used in const expressions
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: muecker at gwdg dot de
  Target Milestone: ---

In the following example, which uses an (undocumented?) extension
that allows using 'y' where a const expression is required,
there is then an incorrect warning:

void test(void)
{
    static const int y = 2;
    enum { A = y };
}

<source>:4:22: warning: variable 'y' set but not used
[-Wunused-but-set-variable]

https://godbolt.org/z/7Y7KE5v59


Clang supports this too but does not warn.

Reply via email to