diff options
author | Eric Fiselier <eric@efcs.ca> | 2018-02-04 01:03:08 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2018-02-04 01:03:08 +0000 |
commit | afeda5c251f9a4696ab9178ecc6d4be7af72c105 (patch) | |
tree | f49c0a1be7b9f7fa4694596d7bd34f775ca19669 /libcxx/test/std/containers/sequences/array/array.cons | |
parent | fc5bd023dd9654c09267c287c3d26ddceeaf4161 (diff) | |
download | bcm5719-llvm-afeda5c251f9a4696ab9178ecc6d4be7af72c105.tar.gz bcm5719-llvm-afeda5c251f9a4696ab9178ecc6d4be7af72c105.zip |
[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.
Summary:
This patch fixes llvm.org/PR35491 and LWG2157 (https://cplusplus.github.io/LWG/issue2157)
The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.
Reviewers: mclow.lists, EricWF
Reviewed By: EricWF
Subscribers: lichray, cfe-commits
Differential Revision: https://reviews.llvm.org/D41223
llvm-svn: 324182
Diffstat (limited to 'libcxx/test/std/containers/sequences/array/array.cons')
-rw-r--r-- | libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp index 7bc62b759c3..9a2a6eaa307 100644 --- a/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp @@ -14,6 +14,14 @@ #include <array> #include <cassert> +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + +struct NoDefault { + NoDefault(int) {} +}; + int main() { { @@ -28,4 +36,13 @@ int main() C c; assert(c.size() == 0); } + { + typedef std::array<NoDefault, 0> C; + C c; + assert(c.size() == 0); + C c1 = {}; + assert(c1.size() == 0); + C c2 = {{}}; + assert(c2.size() == 0); + } } |