[libcxx-commits] [PATCH] D62641: Support arrays in make_shared and allocate_shared (P0674R1)

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 12 12:58:01 PST 2021


zoecarver added inline comments.


================
Comment at: libcxx/include/memory:2710
+    _LIBCPP_HIDE_FROM_ABI
+    void __destroy_elements(_ValueType *__first, int __n) noexcept {
+        using _ValueAlloc = typename __allocator_traits_rebind<_Alloc, _ValueType>::type;
----------------
ldionne wrote:
> I see you're using an `int` here, but what if construction fails at a very large index, the `size_t` to `int` narrowing could be problematic. Is there a reason why you're using `int`?
I'm using `int` because `__n` will become `-1` in the for loop. I could keep it unsigned and just compare `__n < "size"`, but that seems a bit more confusing and would require a second variable. So, I'll make `__n` a `long`. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62641



More information about the libcxx-commits mailing list