Use of atomic_int now fails with address argument to atomic operation must be a pointer to a trivially-copyable type

Bug #1780747 reported by Olivier Tilloy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
llvm-toolchain-6.0 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

This appears to be a regression from clang 6.0.0 to 6.0.1 (also reported upstream: https://bugs.llvm.org/show_bug.cgi?id=37457).

The following code:

#include <stdatomic.h>
int main(int argc, char** argv) {
  atomic_int tmp = ATOMIC_VAR_INIT(-1);
  atomic_store_explicit(&tmp, 42, memory_order_relaxed);
  return 0;
}

fails to build:

$ clang-6.0 -std=gnu11 -Wall test.c
test.c:7:3: error: address argument to atomic operation must be a pointer to a trivially-copyable type ('_Atomic(int) *' invalid)
  atomic_store_explicit(&tmp, 42, 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.

If I replace "atomic_int" by "int", the code builds and works as expected.

ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: clang-6.0 1:6.0.1-2ubuntu1
ProcVersionSignature: Ubuntu 4.15.0-23.25-generic 4.15.18
Uname: Linux 4.15.0-23-generic x86_64
ApportVersion: 2.20.10-0ubuntu3
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Mon Jul 9 10:33:31 2018
InstallationDate: Installed on 2018-07-06 (2 days ago)
InstallationMedia: Ubuntu 18.10 "Cosmic Cuttlefish" - Alpha amd64 (20180630)
SourcePackage: llvm-toolchain-6.0
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Olivier Tilloy (osomon) wrote :
Revision history for this message
Olivier Tilloy (osomon) wrote :

In /usr/lib/gcc/x86_64-linux-gnu/7.3.0/include/stdatomic.h, before the definition of the atomic_store_explicit macro:

   Note that these macros require __typeof__ and __auto_type to remove
   _Atomic qualifiers (and const qualifiers, if those are valid on
   macro operands).

It looks like the regression might be that __auto_type doesn't remove the _Atomic qualifier any longer?

Revision history for this message
Olivier Tilloy (osomon) wrote :

Debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903709

This was fixed with version 1:6.0.1-4.

Changed in llvm-toolchain-6.0 (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.