[libcxx-commits] [PATCH] D80820: [libc++] Overhaul initialization tests in std::array
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 29 10:53:50 PDT 2020
ldionne created this revision.
Herald added subscribers: libcxx-commits, dexonsmith, jkorous.
Herald added a project: libc++.
Herald added a reviewer: libc++.
ldionne added a comment.
ldionne added a parent revision: D80790: [libc++] Remove redundant empty specialization in std::array.
ldionne added a child revision: D80821: [libc++] Return nullptr from an empty array begin().
This patch adds tests that highlight some problems with the current array implementation. Basically, it highlights that we need to pick between:
1. Don't implement constexpr support properly in `std::array<T, 0>`
2. Make `std::array<T, 0>` non-trivial even when T is trivial (which is an ABI break)
3. Return `nullptr` from `std::array<T, 0>::begin()` (which is also an ABI break)
Note that both ABI breaks are benign -- I would be surprised if folks relied on `std::array<T, 0>` at ABI boundaries.
Next, I'll submit a patch that picks (3) as the best solution for now, which is also what other implementations do.
We had a few tests for the different ways to initialize a std::array
here and there, but they were split up and patchy in their coverage.
This patch improves that situation.
It also adds tests for the triviality and aggregate-ness of std::array.
Even though the Standard doesn't explicitly require it, libc++ has been
making std::array<T, N> trivial whenever T is trivial for any value of N.
The patch also adds tests checking that std::array<T, N> is an aggregate
for all values of N.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80820
Files:
libcxx/test/libcxx/containers/sequences/array/triviality.pass.cpp
libcxx/test/std/containers/sequences/array/aggregate.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/initialization.pass.cpp
libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80820.267297.patch
Type: text/x-patch
Size: 18491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200529/4d287261/attachment-0001.bin>
More information about the libcxx-commits
mailing list