public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99588] New: variable set but not used warning on static _Atomic assignment
@ 2021-03-15  1:53 godmar at gmail dot com
  2021-03-15  8:55 ` [Bug c/99588] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: godmar at gmail dot com @ 2021-03-15  1:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99588
           Summary: variable set but not used warning on static _Atomic
                    assignment
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: godmar at gmail dot com
  Target Milestone: ---

A student shared this program with me:

#include <stdio.h>
#include <stdatomic.h>

void test() {
    static _Atomic int x = 0;
    printf("%d\n", x += 1);
}

int main(int argc, char **argv) {
    for(int i = 0; i < 10; i++) {
        test();
    }
}

which on the current x86_64 trunk (and earlier versions) as per godbolt yields
a warning:

<source>: In function 'test':
<source>:5:24: warning: variable 'x' set but not used
[-Wunused-but-set-variable]
    5 |     static _Atomic int x = 0;
      |                        ^
Compiler returned: 0

If the _Atomic modifier is removed, the warning disappears. Is this kosher?

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

end of thread, other threads:[~2021-09-11 14:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15  1:53 [Bug c/99588] New: variable set but not used warning on static _Atomic assignment godmar at gmail dot com
2021-03-15  8:55 ` [Bug c/99588] " rguenth at gcc dot gnu.org
2021-03-16 20:28 ` egallager at gcc dot gnu.org
2021-03-18 11:29 ` jakub at gcc dot gnu.org
2021-03-18 13:14 ` jakub at gcc dot gnu.org
2021-03-19 21:55 ` cvs-commit at gcc dot gnu.org
2021-03-19 21:56 ` jakub at gcc dot gnu.org
2021-03-30 22:41 ` cvs-commit at gcc dot gnu.org
2021-03-31  6:46 ` jakub at gcc dot gnu.org
2021-04-20 23:33 ` cvs-commit at gcc dot gnu.org
2021-04-22 16:51 ` cvs-commit at gcc dot gnu.org
2021-04-22 17:11 ` jakub at gcc dot gnu.org
2021-09-11 14:24 ` pinskia 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).