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

            Bug ID: 26911
           Summary: atomic types not trivially-copyable when clang targets
                    mingw-w64
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: jibz-llvmb...@stdip.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

The following code:

#include <stdatomic.h>
atomic_int foo;
void store(int val)
{
    atomic_store(&foo, val);
}

fails when compiled with clang using mingw-w64 (GCC 5.3.0) headers with:

foo.c:5:2: error: address argument to atomic operation must be a pointer to
      a trivially-copyable type ('_Atomic(int) *' invalid)
        atomic_store(&foo, val);
        ^~~~~~~~~~~~~~~~~~~~~~~
C:\mingw64\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0\include\stdatomic.h:130:3:
note:
      expanded from macro 'atomic_store'
  atomic_store_explicit (PTR, VAL, __ATOMIC_SEQ_CST)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\mingw64\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0\include\stdatomic.h:126:5:
note:
      expanded from macro 'atomic_store_explicit'
    __atomic_store (__atomic_store_ptr, &__atomic_store_tmp, (MO));     \
    ^               ~~~~~~~~~~~~~~~~~~
1 error generated.

I tried both the official installer using --target=x86_64-w64-mingw32 to target
my mingw-w64 install, and using clang in MSYS2 which targets their GCC.

Near line 126 of stdatomic.h, there is a comment about these macros expecting
__typeof__ and __auto_type to remove _Atomic specifier. If I make foo a regular
int it compiles.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to