This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix PR32979 - types with a private std::enable_shared_from_this base break shared_ptr
ClosedPublic

Authored by EricWF on May 10 2017, 2:05 AM.

Details

Summary

This patch fixes bugs.llvm.org/PR32979.

[util.smartptr.shared.const] says:

In the constructor definitions below, enables shared_from_this with p, for a pointer p of type Y*, means
that if Y has an unambiguous and accessible base class that is a specialization of enable_shared_from_-
this.

This means that libc++ needs to respect the access specifier of the base class, and not attempt to construct
and enabled_shared_from_this base if it is private. However access specifiers don't affect overload resolution
so our current implementation will attempt to construct the private base.

This patch uses SFINAE to correctly detect if the shared_ptr input has an accessible enable_shared_from_this
base class.

Diff Detail

Event Timeline

EricWF created this revision.May 10 2017, 2:05 AM
This revision is now accepted and ready to land.May 10 2017, 6:09 AM
EricWF closed this revision.May 10 2017, 12:48 PM