[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
Wed Oct 9 16:06:09 PDT 2024
alexfh wrote:
Thanks for the detailed analysis. I totally agree with the conclusions here. The value of this hardening is obvious, while the ability to (mis-)use unique_ptr this way is questionable on its own. Luckily (though no surprise ;) this was an isolated case and the code has already been fixed.
> To be unambiguous, we should perhaps add something to the various `std::unique_ptr` constructors that says "the pointer used to initialized the `unique_ptr` must be such that calling the deleter on it disposes of the pointer in a valid way", but we'd have to be careful not to step on the toes of `unique_ptr`'s ability to hold incomplete types.
Making this part of the standard unambiguous would definitely be welcome.
> Frankly, I'm not certain what to do with this. I feel like it would be really unfortunate to drop this hardening check on a slightly ambiguous technicality since it can deliver a ton of value in the real world. I think I'll email the reflector to see what the sentiment is like over there.
I almost feel sorry for bringing this up ;) But hopefully, this will result in improving the standard rather than creating an obstacle for library hardenings.
https://github.com/llvm/llvm-project/pull/91798
More information about the libcxx-commits
mailing list