diff --git a/stl/inc/array b/stl/inc/array index c417a1826b4..9c8b39023ed 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -615,6 +615,8 @@ template array(_First, _Rest...) -> array::type, 1 + sizeof...(_Rest)>; #endif // _HAS_CXX17 +struct _Empty_array_element {}; + template class array<_Ty, 0> { public: @@ -728,7 +730,7 @@ public: _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 - return _Elems[0]; + return *data(); } _NODISCARD const_reference operator[](size_type) const noexcept /* strengthened */ { @@ -736,7 +738,7 @@ public: _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 - return _Elems[0]; + return *data(); } _NODISCARD reference front() noexcept /* strengthened */ { @@ -744,7 +746,7 @@ public: _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 - return _Elems[0]; + return *data(); } _NODISCARD const_reference front() const noexcept /* strengthened */ { @@ -752,7 +754,7 @@ public: _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 - return _Elems[0]; + return *data(); } _NODISCARD reference back() noexcept /* strengthened */ { @@ -760,7 +762,7 @@ public: _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 - return _Elems[0]; + return *data(); } _NODISCARD const_reference back() const noexcept /* strengthened */ { @@ -768,7 +770,7 @@ public: _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 - return _Elems[0]; + return *data(); } _NODISCARD _CONSTEXPR17 _Ty* data() noexcept { @@ -783,7 +785,9 @@ public: _Xout_of_range("invalid array subscript"); } - _Ty _Elems[1]; + conditional_t, _Is_implicitly_default_constructible<_Ty>>, _Ty, + _Empty_array_element> + _Elems[1]; }; template ::value, int> = 0> diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 2ea46e7fd6b..ea2271fa916 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -69,6 +69,9 @@ std/language.support/support.limits/support.limits.general/concepts.version.pass # Bogus test believes that optional cannot be a literal type std/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp:0 FAIL +# Bogus test believes that copyability of array must be the same as array +std/containers/sequences/array/array.cons/implicit_copy.pass.cpp FAIL + # *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX *** # Tracked by VSO-593630 " Enable libcxx filesystem tests" @@ -348,13 +351,6 @@ std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp FAIL std/containers/sequences/array/array.fill/fill.fail.cpp FAIL std/containers/sequences/array/array.swap/swap.fail.cpp FAIL -# GH-942 : std::array doesn't compile - when type is not default constructible -std/containers/sequences/array/array.cons/implicit_copy.pass.cpp FAIL -std/containers/sequences/array/array.cons/initialization.pass.cpp FAIL -std/containers/sequences/array/array.data/data_const.pass.cpp FAIL -std/containers/sequences/array/array.data/data.pass.cpp FAIL -std/containers/sequences/array/iterators.pass.cpp FAIL - # GH-1006 : debug checks for predicates are observable std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp FAIL std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp FAIL diff --git a/tests/libcxx/skipped_tests.txt b/tests/libcxx/skipped_tests.txt index 9f247e32f38..401947ec26a 100644 --- a/tests/libcxx/skipped_tests.txt +++ b/tests/libcxx/skipped_tests.txt @@ -69,6 +69,9 @@ language.support\support.limits\support.limits.general\concepts.version.pass.cpp # Bogus test believes that optional cannot be a literal type utilities\optional\optional.object\optional.object.dtor\dtor.pass.cpp +# Bogus test believes that copyability of array must be the same as array +containers\sequences\array\array.cons\implicit_copy.pass.cpp + # *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX *** # Tracked by VSO-593630 " Enable libcxx filesystem tests" @@ -348,13 +351,6 @@ input.output\file.streams\fstreams\filebuf.virtuals\underflow.pass.cpp containers\sequences\array\array.fill\fill.fail.cpp containers\sequences\array\array.swap\swap.fail.cpp -# GH-942 : std::array doesn't compile - when type is not default constructible -containers\sequences\array\array.cons\implicit_copy.pass.cpp -containers\sequences\array\array.cons\initialization.pass.cpp -containers\sequences\array\array.data\data_const.pass.cpp -containers\sequences\array\array.data\data.pass.cpp -containers\sequences\array\iterators.pass.cpp - # GH-1006 : debug checks for predicates are observable algorithms\alg.sorting\alg.merge\inplace_merge_comp.pass.cpp algorithms\alg.sorting\alg.min.max\minmax_init_list_comp.pass.cpp