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

            Bug ID: 71949
           Summary: ATOMIC_FLAG_INIT definition in stdatomic.h
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick.pelissier at gmail dot com
  Target Milestone: ---

Compiling the following program, I get one error for one kind of affectation to
ATOMIC_FLAG_INIT :

#include <stdatomic.h>
void f(void) {
  atomic_flag f1 = ATOMIC_FLAG_INIT;
  atomic_flag f2;
  f2 =  ATOMIC_FLAG_INIT;
}

$ /opt/gcc/bin/gcc -c flag.c
In file included from flag.c:1:0:
flag.c: In function 'f':
flag.c:6:9: error: expected expression before '{' token
   f2 =  ATOMIC_FLAG_INIT;
         ^

$ /opt/gcc/bin/gcc --version
gcc (GCC) 6.1.0

I expected both construction to be valid.

Proposed solution: fix definition of ATOMIC_FLAG_INIT in stdatomic.h into:

#define ATOMIC_FLAG_INIT ((atomic_flag) { 0 })

instead of 

#define ATOMIC_FLAG_INIT        { 0 }

Reply via email to