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

Jonathan Wakely jwakely.gcc@gmail.com
Thu Mar 5 23:29:00 GMT 2015


On 5 March 2015 at 23:06, Maik Zumstrull wrote:
> 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

Violating the precondition is undefined behaviour, so there's no
guarantee it will fail to compile.


> somebody in the know (jwakely?) comment whether this is supposed to
> compile, and would work as implied?

Anyway, with current trunk it fails:
/home/jwakely/gcc/5/include/c++/5.0.0/atomic:170:7: error: static
assertion failed: std::atomic requires a trivially copyable type

That wasn't possible previously because we didn't support the
is_trivially_copyable trait.



More information about the Gcc-help mailing list