[Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size

roman at binarylife dot net gcc-bugzilla@gcc.gnu.org
Fri Mar 28 12:54:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60695

            Bug ID: 60695
           Summary: std::atomic<X> doesn't work when X is of zero size
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roman at binarylife dot net

$ cat test.cc 
#include <atomic>

struct X {
  char stuff[0];
};

X foo(std::atomic<X>& a, X x) {
  a = x;
  return a;
}

$ g++ -std=c++11 -c test.cc 
In file included from test.cc:1:0:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘void
std::atomic<_Tp>::store(_Tp, std::memory_order) [with _Tp = X;
std::memory_order = std::memory_order]’:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:183:18:   required from ‘_Tp
std::atomic<_Tp>::operator=(_Tp) [with _Tp = X]’
test.cc:8:5:   required from here
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:199:39: error: argument 1 of
‘__atomic_store’ must be a pointer to a nonzero size object
       { __atomic_store(&_M_i, &__i, _m); }
                                       ^
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘_Tp
std::atomic<_Tp>::load(std::memory_order) const [with _Tp = X;
std::memory_order = std::memory_order]’:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:176:21:   required from
‘std::atomic<_Tp>::operator _Tp() const [with _Tp = X]’
test.cc:9:10:   required from here
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:209:31: error: argument 1 of
‘__atomic_load’ must be a pointer to a nonzero size object
  __atomic_load(&_M_i, &tmp, _m); 
                               ^
$ g++ --version
g++ (GCC) 4.9.0 20140327 (experimental)
...


More information about the Gcc-bugs mailing list