[libcxx-commits] [libcxx] [libc++] Add an ABI setting to harden unique_ptr<T[]>::operator[] (PR #91798)
Alexander Kornienko via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Oct 5 05:20:09 PDT 2024
alexfh wrote:
What about a case when a `std::unique_ptr<T[]>` with a default deleter temporarily points to a memory allocated with something but `new T[]`? If the code ensures the pointer is always reset before `std::unique_ptr` is destroyed, and the default deleter is never used. Something like in this example: https://gcc.godbolt.org/z/4fczP6e1q
If we skip the question why would one do that at all (I'm about to ask the author(s)), it seems like this is a valid use of the `std::unique_ptr<>` according to the C++20 standard. Or am I missing something?
https://github.com/llvm/llvm-project/pull/91798
More information about the libcxx-commits
mailing list