[libcxx-commits] [PATCH] D80790: [libc++] Remove redundant empty specialization in std::array

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 29 10:21:18 PDT 2020


ldionne added a comment.

In D80790#2063354 <https://reviews.llvm.org/D80790#2063354>, @EricWF wrote:

> Why is this code an improvement?
>
> First, it causes substantially fewer misuses of `array<T, 0>` to be caught. 
>  It admits for all sorts of out-of-bounds memory accesses that weren't possible before.


How is that true? It's actually quite the opposite -- before, we would *only* catch invalid accesses on `std::array<T, 0>` -- with this patch, we catch them for any array size. Look at `std::array<T, N>::operator[]`, which now has `_LIBCPP_ASSERT` when it previously had nothing (only the `std::array<T, 0>` one had an assert).

Apart from that significant improvement, it also doesn't duplicate the whole definition of `std::array` just to handle the empty case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80790





More information about the libcxx-commits mailing list