[libcxx-commits] [PATCH] D62259: shared_ptr changes from library fundamentals (P0414R2)

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 6 19:39:42 PDT 2019


zoecarver marked an inline comment as done.
zoecarver added inline comments.


================
Comment at: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp:42
     {
-    A* ptr = new A;
-    std::shared_ptr<void> p(ptr);
-    assert(A::count == 1);
-    assert(p.use_count() == 1);
-    assert(p.get() == ptr);
+//     A* ptr = new A;
+//     std::shared_ptr<void> p(ptr);
----------------
zoecarver wrote:
> I am not so sure about `shared_ptr<void>`. The standard says "The expression delete[] p, when T is an array type, or delete p, when T is not an array type, shall have well-defined behavior, and shall not throw exceptions." Meaning that `delete T` must be well defined. But the standard also says `delete void` is not well defined: "This implies that an object cannot be deleted using a pointer of type void* because there are no objects of type void." Therefore, I think `shared_ptr<void>` goes against the standard. 
> 
> Either way, for the overload tested here, we will have to pick between creating a deleter for type `T` and type `Y`. The former works for arrays and the latter works for `void`. 
The standard says `delete p` must be well defined. Meaning `delete Y` must be well defined. Not `delete T`. My bad.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62259/new/

https://reviews.llvm.org/D62259





More information about the libcxx-commits mailing list