[llvm-bugs] [Bug 37457] New: Use of _Atomic() now fails with address argument to atomic operation must be a pointer to a trivially-copyable type

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 14 10:51:18 PDT 2018


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

            Bug ID: 37457
           Summary: Use of _Atomic() now fails  with address argument to
                    atomic operation must be a pointer to a
                    trivially-copyable type
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jgunthorpe at gmail.com
                CC: llvm-bugs at lists.llvm.org

This must have become broken in the last few days, as we have a CI tracking the
APT packages for trusty of clang-5.0 which worked up until very recently.

It works fine in clang release 5.0.2, 6.0.0, gcc-7, etc.

Test case:

#include <stdatomic.h>

int main(int argc,const char *argv[])
{
        int tmp;
        atomic_store_explicit((_Atomic(int) *)&tmp, 0, memory_order_relaxed);

        return 0;
}

$ clang-5.0 --version
clang version 5.0.2-svn328729-1~exp1~20180509123505.100 (branches/release_50)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang-5.0 -std=gnu11 -Wall t.c
t.c:6:9: error: address argument to atomic operation must be a pointer to a
trivially-copyable type ('_Atomic(int) *' invalid)
        atomic_store_explicit((_Atomic(int) *)&tmp, 0, memory_order_relaxed);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.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.

$ clang-6.0 --version
clang version 6.0.1-svn331815-1~exp1~20180510084719.80 (branches/release_60)
$ clang-6.0 -std=gnu11 -Wall t.c
t.c:6:9: error: address argument to atomic operation must be a pointer to a
trivially-copyable type ('_Atomic(int) *' invalid)
        atomic_store_explicit((_Atomic(int) *)&tmp, 0, memory_order_relaxed);

While these work fine (official pre-compiled tar releases on ubuntu Xenial):

$ ./clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang  --version
clang version 5.0.2 (tags/RELEASE_502/final)
$ ./clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-16.04/bin/clang -std=gnu11 -Wall
t.c

$ ./clang+llvm-6.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang --version
clang version 6.0.0 (tags/RELEASE_600/final)
$ ./clang+llvm-6.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang -std=gnu11 -Wall
t.c

-- 
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/20180514/04827c2f/attachment-0001.html>


More information about the llvm-bugs mailing list