Created attachment 30076 [details] Test case http://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr says: "When constructing a shared_ptr from a raw pointer to an object of a type derived from std::enable_shared_from_this, the constructors of shared_ptr detect other owners of the object through the weak reference stored in that base class. This allows ownership of the object to be shared with existing shared_ptrs. Otherwise, it is undefined behavior to construct a shared_ptr for an object that is already managed by another shared_ptr." Therefore, I gather the attached program should share ownership, but it doesn't: It says "gp2.use_count() = 1;" and aborts due to double deletion. Using shared_from_this() works, though, so it's probably not a serious problem.
cppreference is wrong. This exact case has been discussed on the LWG reflector and everyone agreed it's invalid. The shared_ptr(Y*) constructor use_count() == 1 as a postcondition, which is not compatible with the claim that you can share ownership with existing shared_ptr objects.
This is http://cplusplus.github.io/LWG/lwg-active.html#2179 but if the behaviour changes I'll eat my hat.