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
This commit is contained in:
parent
7ae4ad2898
commit
368b7a304e
5 changed files with 69 additions and 27 deletions
|
@ -1,3 +1,15 @@
|
|||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
31
libstdc++-v3/testsuite/20_util/memory/16505.cc
Normal file
31
libstdc++-v3/testsuite/20_util/memory/16505.cc
Normal file
|
@ -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&);
|
Loading…
Add table
Reference in a new issue