https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822
--- Comment #30 from Michi Henning <michi at triodia dot com> --- (In reply to Jonathan Wakely from comment #29) > > make_shared<T>(args) doesn't always do the same thing as shared_ptr<T>(new > > T(args)) > > It does do effectively the same thing. The difference in behaviour is > because when you use shared_ptr<T>(new T(this)) the implicit cast happens > inside the class, and the compiler can resolve it without inspecting the > stable. Yes, I understand why it happens, and why the current behavior conforms to the standard. It's just that, from an application programmer's point of view, this is in the "ultra-unexpected category". > It should be possible to add a warning for the case where the cast happens > inside the class (which doesn't crash, but is still UB) but it won't be > possible to warn for the other cases, because at the site of the implicit > cast the compiler doesn't know whether the pointer refers to a constructed > object or not. I've created PR 70644. Most sterling, thank you! Michi.