diff options
author | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-02-08 11:33:48 +0000 |
---|---|---|
committer | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-02-08 11:33:48 +0000 |
commit | 2b20304def44a0e3c4ab4ae90f50d4c4449ce03d (patch) | |
tree | fca74d6f819afec7856cb5e37500974845b37d5d /libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp | |
parent | 25dc3d27ea816aeff1d30929845efb0db934f0b3 (diff) | |
download | bcm5719-llvm-2b20304def44a0e3c4ab4ae90f50d4c4449ce03d.tar.gz bcm5719-llvm-2b20304def44a0e3c4ab4ae90f50d4c4449ce03d.zip |
[libcxx] Avoid spurious construction of valarray elements
Summary:
Currently libc++ implements some operations on valarray by using the
resize method. This method has a parameter with a default value.
Because of this, valarray may spuriously construct and destruct
objects of valarray's element type.
This patch fixes this issue and adds corresponding test cases.
Reviewers: EricWF, mclow.lists
Reviewed By: mclow.lists
Subscribers: rogfer01, cfe-commits
Differential Revision: https://reviews.llvm.org/D41992
llvm-svn: 324596
Diffstat (limited to 'libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp')
-rw-r--r-- | libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp b/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp index f46e0bf28cf..9933322de96 100644 --- a/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp +++ b/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp @@ -16,6 +16,13 @@ #include <valarray> #include <cassert> +struct S { + S() { ctor_called = true; } + static bool ctor_called; +}; + +bool S::ctor_called = false; + int main() { { @@ -34,4 +41,9 @@ int main() std::valarray<std::valarray<double> > v; assert(v.size() == 0); } + { + std::valarray<S> v; + assert(v.size() == 0); + assert(!S::ctor_called); + } } |