public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105208] New: incorrect -Wunused-but-set-variable for static const variables used in const expressions
@ 2022-04-10 19:20 muecker at gwdg dot de
  2023-03-24  7:42 ` [Bug c/105208] " muecker at gwdg dot de
  0 siblings, 1 reply; 2+ messages in thread
From: muecker at gwdg dot de @ 2022-04-10 19:20 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/105208] incorrect -Wunused-but-set-variable for static const variables used in const expressions
  2022-04-10 19:20 [Bug c/105208] New: incorrect -Wunused-but-set-variable for static const variables used in const expressions muecker at gwdg dot de
@ 2023-03-24  7:42 ` muecker at gwdg dot de
  0 siblings, 0 replies; 2+ messages in thread
From: muecker at gwdg dot de @ 2023-03-24  7:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Martin Uecker <muecker at gwdg dot de> ---
Still affects 12.x but seems to have disappeared on trunk.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-24  7:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-10 19:20 [Bug c/105208] New: incorrect -Wunused-but-set-variable for static const variables used in const expressions muecker at gwdg dot de
2023-03-24  7:42 ` [Bug c/105208] " muecker at gwdg dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).