<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - atomic types not trivially-copyable when clang targets mingw-w64"
   href="https://llvm.org/bugs/show_bug.cgi?id=26911">26911</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>atomic types not trivially-copyable when clang targets mingw-w64
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows XP
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jibz-llvmbugs@stdip.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>