aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/valarray
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2013-06-21 14:23:15 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-06-21 14:23:15 +0000
commitb0ad3635b63e6786a8216aa8ec3d4436fa9ae9ac (patch)
tree627954bccc61124f7e77d0b00ca7e0ff1f8b6893 /libstdc++-v3/include/std/valarray
parent927f908bf879a79ec26af82671e2a5b93073a8a2 (diff)
downloadgcc-b0ad3635b63e6786a8216aa8ec3d4436fa9ae9ac.zip
gcc-b0ad3635b63e6786a8216aa8ec3d4436fa9ae9ac.tar.gz
gcc-b0ad3635b63e6786a8216aa8ec3d4436fa9ae9ac.tar.bz2
re PR libstdc++/57666 (valarray<T>::operator= in c++11 mode does not adapt to size)
2013-06-21 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/57666 * include/std/valarray (valarray<>::operator=(const _Expr<>&)): Implement correctly C++11 26.6.2.3/1. * testsuite/26_numerics/valarray/dr630-3.C: New. From-SVN: r200305
Diffstat (limited to 'libstdc++-v3/include/std/valarray')
-rw-r--r--libstdc++-v3/include/std/valarray17
1 files changed, 15 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/valarray b/libstdc++-v3/include/std/valarray
index 6bee6e0..be96af6 100644
--- a/libstdc++-v3/include/std/valarray
+++ b/libstdc++-v3/include/std/valarray
@@ -819,8 +819,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline valarray<_Tp>&
valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
{
- _GLIBCXX_DEBUG_ASSERT(_M_size == __e.size());
- std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 630. arrays of valarray.
+ if (_M_size == __e.size())
+ std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
+ else
+ {
+ if (_M_data)
+ {
+ std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
+ std::__valarray_release_memory(_M_data);
+ }
+ _M_size = __e.size();
+ _M_data = __valarray_get_storage<_Tp>(_M_size);
+ std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data));
+ }
return *this;
}