diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-07-14 23:57:34 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-07-14 23:57:34 +0000 |
commit | 368b7a304e674df0e140b6dc164e670650c56486 (patch) | |
tree | 810e6e95b8bb967e4488292e927010f0ff3f9e78 | |
parent | 7ae4ad2898ab2f7f2afbadae3cdc4d24221eb034 (diff) | |
download | gcc-368b7a304e674df0e140b6dc164e670650c56486.zip gcc-368b7a304e674df0e140b6dc164e670650c56486.tar.gz gcc-368b7a304e674df0e140b6dc164e670650c56486.tar.bz2 |
re PR libstdc++/16505 ([3.4 only] std::uninitialized_fill_n() incorrect signature)
2004-07-14 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/16505
* include/bits/stl_uninitialized.h (uninitialized_fill_n): Fix
the signature to return void, as per 20.4.4.3.
* include/bits/stl_vector.h (vector::vector(size_type,
const value_type&, const allocator_type&), vector::vector(size_type),
vector::_M_initialize_dispatch): Adjust callers.
* include/bits/vector.tcc (vector<>::_M_fill_assign,
vector<>::_M_fill_insert): Likewise.
* testsuite/20_util/memory/16505.cc: New.
From-SVN: r84720
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_uninitialized.h | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_vector.h | 26 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/vector.tcc | 15 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/memory/16505.cc | 31 |
5 files changed, 69 insertions, 27 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a4c2ccc..6c8101f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,17 @@ 2004-07-14 Paolo Carlini <pcarlini@suse.de> + PR libstdc++/16505 + * include/bits/stl_uninitialized.h (uninitialized_fill_n): Fix + the signature to return void, as per 20.4.4.3. + * include/bits/stl_vector.h (vector::vector(size_type, + const value_type&, const allocator_type&), vector::vector(size_type), + vector::_M_initialize_dispatch): Adjust callers. + * include/bits/vector.tcc (vector<>::_M_fill_assign, + vector<>::_M_fill_insert): Likewise. + * testsuite/20_util/memory/16505.cc: New. + +2004-07-14 Paolo Carlini <pcarlini@suse.de> + * testsuite/22_locale/locale/cons/12658_thread-1.cc, 12658_thread-2.cc: Use __gnu_test::try_named_locale. diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index f4f8d18..898658c 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -82,7 +82,7 @@ namespace std _ForwardIterator __cur = __result; try { - for ( ; __first != __last; ++__first, ++__cur) + for (; __first != __last; ++__first, ++__cur) std::_Construct(&*__cur, *__first); return __cur; } @@ -145,7 +145,7 @@ namespace std _ForwardIterator __cur = __first; try { - for ( ; __cur != __last; ++__cur) + for (; __cur != __last; ++__cur) std::_Construct(&*__cur, __x); } catch(...) @@ -190,7 +190,7 @@ namespace std _ForwardIterator __cur = __first; try { - for ( ; __n > 0; --__n, ++__cur) + for (; __n > 0; --__n, ++__cur) std::_Construct(&*__cur, __x); return __cur; } @@ -206,17 +206,17 @@ namespace std * @param first An input iterator. * @param n The number of copies to make. * @param x The source value. - * @return first+n + * @return Nothing. * * Like fill_n(), but does not require an initialized output range. */ template<typename _ForwardIterator, typename _Size, typename _Tp> - inline _ForwardIterator + inline void uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD; - return std::__uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); + std::__uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); } // Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 1682986..2e95845 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -118,7 +118,8 @@ namespace _GLIBCXX_STD void _M_deallocate(_Tp* __p, size_t __n) - { if (__p) + { + if (__p) _M_impl.deallocate(__p, __n); } }; @@ -198,9 +199,10 @@ namespace _GLIBCXX_STD vector(size_type __n, const value_type& __value, const allocator_type& __a = allocator_type()) : _Base(__n, __a) - { this->_M_impl._M_finish = std::uninitialized_fill_n(this-> - _M_impl._M_start, - __n, __value); } + { + std::uninitialized_fill_n(this->_M_impl._M_start, __n, __value); + this->_M_impl._M_finish = this->_M_impl._M_start + __n; + } /** * @brief Create a %vector with default elements. @@ -212,10 +214,10 @@ namespace _GLIBCXX_STD explicit vector(size_type __n) : _Base(__n, allocator_type()) - { this->_M_impl._M_finish = std::uninitialized_fill_n(this-> - _M_impl._M_start, - __n, - value_type()); } + { + std::uninitialized_fill_n(this->_M_impl._M_start, __n, value_type()); + this->_M_impl._M_finish = this->_M_impl._M_start + __n; + } /** * @brief %Vector copy constructor. @@ -231,8 +233,7 @@ namespace _GLIBCXX_STD { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(), __x.end(), this-> - _M_impl._M_start); - } + _M_impl._M_start); } /** * @brief Builds a %vector from a range. @@ -777,9 +778,8 @@ namespace _GLIBCXX_STD { this->_M_impl._M_start = _M_allocate(__n); this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; - this->_M_impl._M_finish = std::uninitialized_fill_n(this-> - _M_impl._M_start, - __n, __value); + std::uninitialized_fill_n(this->_M_impl._M_start, __n, __value); + this->_M_impl._M_finish = this->_M_impl._M_end_of_storage; } // Called by the range constructor to implement [23.1.1]/9 diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 3840185..5337035 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -176,10 +176,9 @@ namespace _GLIBCXX_STD else if (__n > size()) { std::fill(begin(), end(), __val); - this->_M_impl._M_finish = std::uninitialized_fill_n(this-> - _M_impl._M_finish, - __n - size(), - __val); + std::uninitialized_fill_n(this->_M_impl._M_finish, + __n - size(), __val); + this->_M_impl._M_finish += __n - size(); } else erase(fill_n(begin(), __n, __val), end()); @@ -336,15 +335,15 @@ namespace _GLIBCXX_STD { __new_finish = std::uninitialized_copy(begin(), __position, __new_start); - __new_finish = std::uninitialized_fill_n(__new_finish, __n, - __x); + std::uninitialized_fill_n(__new_finish, __n, __x); + __new_finish += __n; __new_finish = std::uninitialized_copy(__position, end(), __new_finish); } catch(...) { - std::_Destroy(__new_start,__new_finish); - _M_deallocate(__new_start.base(),__len); + std::_Destroy(__new_start, __new_finish); + _M_deallocate(__new_start.base(), __len); __throw_exception_again; } std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); diff --git a/libstdc++-v3/testsuite/20_util/memory/16505.cc b/libstdc++-v3/testsuite/20_util/memory/16505.cc new file mode 100644 index 0000000..87ef178 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/memory/16505.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 20.4.4 specialized algorithms + +// { dg-do compile } + +#include <memory> + +// libstdc++/16505 + +struct S { }; + +template + void + std::uninitialized_fill_n<S*, int, S>(S*, int, const S&); |