public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96571] New: Bad "set but not used" warning with _Generic
@ 2020-08-11 16:33 jsm28 at gcc dot gnu.org
  2020-08-12  9:12 ` [Bug c/96571] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2020-08-11 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96571
           Summary: Bad "set but not used" warning with _Generic
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jsm28 at gcc dot gnu.org
  Target Milestone: ---

Compile the following with -Wall:

enum E { V };

int
f (void)
{
  enum E v;
  return _Generic (v, enum E : 0);
}

This produces a warning:

t.c: In function 'f':
t.c:6:10: warning: variable 'v' set but not used [-Wunused-but-set-variable]
    6 |   enum E v;
      |          ^

It's arguable whether the variable is "used" when it's only referenced in the
controlling expression of _Generic (so never actually evaluated), but it's
certainly not set.

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

end of thread, other threads:[~2020-09-17 17:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
2020-08-12  9:12 ` [Bug c/96571] " jakub at gcc dot gnu.org
2020-08-13 16:40 ` jakub at gcc dot gnu.org
2020-08-18  5:52 ` cvs-commit at gcc dot gnu.org
2020-08-25 17:45 ` cvs-commit at gcc dot gnu.org
2020-09-16 19:23 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:57 ` jakub at gcc dot gnu.org

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).