Page MenuHomePhabricator

[libc++] Overhaul initialization tests in std::array
AbandonedPublic

Authored by ldionne on May 29 2020, 10:40 AM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

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.

Diff Detail

Event Timeline

ldionne created this revision.May 29 2020, 10:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2020, 10:40 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

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.

ldionne abandoned this revision.May 29 2020, 12:04 PM

I'll merge the tests into https://reviews.llvm.org/D80821 -- abandoning this.

Sorry for the confusion.