Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize array<T, 0>'s single element #3863

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stl/inc/array
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ public:

conditional_t<disjunction_v<is_default_constructible<_Ty>, _Is_implicitly_default_constructible<_Ty>>, _Ty,
_Empty_array_element>
_Elems[1];
_Elems[1]{};

private:
[[noreturn]] static void _Xran() {
Expand Down
7 changes: 5 additions & 2 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,9 @@ std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get
std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp FAIL

# LIT's ADDITIONAL_COMPILE_FLAGS is problematic
std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cpp SKIPPED
std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp:0 FAIL
std/utilities/format/format.functions/escaped_output.ascii.pass.cpp SKIPPED
std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cpp SKIPPED
std/utilities/variant/variant.variant/implicit_ctad.pass.cpp SKIPPED

# libc++ speculatively implements LWG-3645
Expand Down Expand Up @@ -713,6 +714,9 @@ std/time/time.syn/formatter.year_month_weekday.pass.cpp:0 FAIL
std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp FAIL
std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp:1 FAIL

# This test assumes that array<int, 0> is not const-default-constructible.
std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp:1 FAIL


# *** LIKELY STL BUGS ***
# Not analyzed, likely STL bugs. Various assertions.
Expand Down Expand Up @@ -978,7 +982,6 @@ std/algorithms/algorithms.results/in_found_result.pass.cpp:0 FAIL
std/algorithms/algorithms.results/min_max_result.pass.cpp:0 FAIL
std/algorithms/ranges_robust_against_dangling.pass.cpp FAIL
std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp FAIL
std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp:0 FAIL
std/containers/sequences/deque/abi.compile.pass.cpp FAIL
std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp:0 FAIL
std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp:0 FAIL
Expand Down
7 changes: 7 additions & 0 deletions tests/tr1/tests/array/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#include <array>
#include <stdexcept>

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)

// Also test DevCom-10299275, in which array<int, 0> was not a valid constant expression
// since we didn't initialize the single element.
constexpr STD array<int, 0> empty_array;
STATIC_ASSERT(empty_array.size() == 0);

StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved
void test_main() { // test header <array>
STD array<int, 0> a0 = {};

Expand Down