[llvm-bugs] [Bug 37922] New: ISO C++ forbids declaration of '_Atomic' with no type

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 25 01:02:23 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37922

            Bug ID: 37922
           Summary: ISO C++ forbids declaration of '_Atomic' with no type
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The code is as follow:

struct AtomicInt
{
 _Atomic(int) Atomic;
};
AtomicInt GlobalAtomic0 = {0};
constexpr AtomicInt GlobalAtomic1 = {0};

clang++ accepts the code, but g++ rejects the code:

code0.c.cpp:3:13: error: ISO C++ forbids declaration of '_Atomic' with no type
[-fpermissive]
  _Atomic(int) Atomic;
             ^
code0.c.cpp:3:13: error: expected ';' at end of member declaration
  _Atomic(int) Atomic;
             ^
              ;
code0.c.cpp:3:15: error: 'Atomic' does not name a type; did you mean
'AtomicInt'?
  _Atomic(int) Atomic;
               ^~~~~~
               AtomicInt
code0.c.cpp:5:29: error: too many initializers for 'AtomicInt'
 AtomicInt GlobalAtomic0 = {0};
                             ^
code0.c.cpp:6:39: error: too many initializers for 'const AtomicInt'
 constexpr AtomicInt GlobalAtomic1 = {0};

This code looks ill-formed, right?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180625/0eaed90c/attachment.html>


More information about the llvm-bugs mailing list