Why does std::atomic< std::shared_ptr<string> > compile?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I've just had a discussion triggered by the blog post at
http://bert-hubert.blogspot.de/2015/03/some-notes-on-sharedptr-atomicity-and.html,
and in the process, I discovered that this snippet:

#include <atomic>
#include <cstdlib>
#include <memory>
#include <string>

int main(int argc, char **argv) {
  std::atomic< std::shared_ptr<std::string> > my_atomic_shared_pointer;

  return EXIT_SUCCESS;
}

Does, in fact, compile on gcc 4.9.2 (Fedora). However, based on
http://en.cppreference.com/w/cpp/atomic/atomic I would expect this to
error out, since std::shared_ptr is surely not TriviallyCopyable. Can
somebody in the know (jwakely?) comment whether this is supposed to
compile, and would work as implied?

FWIW, as soon as I try to actually do anything with the object, i.e.

my_atomic_shared_pointer = std::make_shared<std::string>("foo");

it fails to link with "undefined reference to `__atomic_store_16'".

Thanks in advance,

Maik Zumstrull




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux