[libc++] Fix issues with the triviality of std::array
authorLouis Dionne <ldionne@apple.com>
Fri, 29 May 2020 23:32:55 +0000 (16:32 -0700)
committerFangrui Song <maskray@google.com>
Fri, 29 May 2020 23:32:55 +0000 (16:32 -0700)
commit7265ff928a974a844b6301c139cbb0f957532da9
treeef9cfc22bcdfda5a35eb450b6209a3eadc3fd99f
parent03559c684a9bfe4de142fa4a7d2ef1edf08a8ad3
[libc++] Fix issues with the triviality of std::array

The Standard is currently unimplementable. We have to pick between:

1. Not implementing constexpr support properly in std::array<T, 0>
2. Making std::array<T, 0> non-trivial even when T is trivial
3. Returning nullptr from std::array<T, 0>::begin()

Libc++ initially picked (1). In 77b9abfc8e89, we started implementing constexpr properly, but lost the guarantee of triviality. Since it seems like both (1) and (2) are really important, it seems like (3) is the only viable option for libc++, after all. This is also what other implementations are doing.

This patch moves libc++ from (1) to (3).

It also:
- Improves the test coverage for the various ways of initializing std::array
- Adds tests for the triviality of std::array
- Adds tests for the aggregate-ness of std::array

Reviewed By: #libc, miscco, EricWF, zoecarver

Differential Revision: https://reviews.llvm.org/D80821
libcxx/include/array
libcxx/test/libcxx/containers/sequences/array/triviality.pass.cpp [new file with mode: 0644]
libcxx/test/std/containers/sequences/array/aggregate.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp [deleted file]
libcxx/test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp [new file with mode: 0644]
libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp [deleted file]
libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
libcxx/test/std/containers/sequences/array/iterators.pass.cpp