[PATCH] D30837: [libcxx] Support for shared_ptr<T()>

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 27 12:58:10 PDT 2017


EricWF added a comment.

This patch seems to support constructing a `shared_ptr<FuncType>` without providing a non-default deleter. I don't think this should work because the default deleter will attempt to free a function pointer, which is never valid. (Although I think this case will still cause a compile error).



================
Comment at: include/memory:3896
+
+template <class _Tp> struct __shared_ptr_default_allocator<_Tp, false>
+{
----------------
I would just handle this case with the primary template rather than a complete specialization.


================
Comment at: include/memory:3903
+{
+    typedef allocator<int> type;
+};
----------------
Using an arbitrary and unrelated allocator type `std::allocator<int>` still makes me nervous. I would rather use a custom allocator type written only for this use case.


https://reviews.llvm.org/D30837





More information about the cfe-commits mailing list