re PR libstdc++/8347 (empty vector range used in string construction causes core dump.)
2002-10-27 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/8347 * include/bits/basic_string.tcc (string::_S_construct(_InIter, _InIter, const _Alloc&, forward_iterator_tag)): Do not throw logic error if __beg == NULL && __end == __beg. (string::string(const _CharT*, const _Alloc&)): Tweak. * testsuite/21_strings/ctor_copy_dtor.cc: Add test05 from PR. From-SVN: r58577
This commit is contained in:
parent
881fc35459
commit
085825b83b
3 changed files with 26 additions and 5 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2002-10-27 Paolo Carlini <pcarlini@unitus.it>
|
||||||
|
|
||||||
|
PR libstdc++/8347
|
||||||
|
* include/bits/basic_string.tcc
|
||||||
|
(string::_S_construct(_InIter, _InIter, const _Alloc&,
|
||||||
|
forward_iterator_tag)): Do not throw logic error if
|
||||||
|
__beg == NULL && __end == __beg.
|
||||||
|
(string::string(const _CharT*, const _Alloc&)): Tweak.
|
||||||
|
* testsuite/21_strings/ctor_copy_dtor.cc: Add test05 from PR.
|
||||||
|
|
||||||
2002-10-24 Hans-Peter Nilsson <hp@bitrange.com>
|
2002-10-24 Hans-Peter Nilsson <hp@bitrange.com>
|
||||||
|
|
||||||
PR other/3337
|
PR other/3337
|
||||||
|
|
|
@ -139,13 +139,13 @@ namespace std
|
||||||
{
|
{
|
||||||
size_type __dnew = static_cast<size_type>(distance(__beg, __end));
|
size_type __dnew = static_cast<size_type>(distance(__beg, __end));
|
||||||
|
|
||||||
|
if (__beg == __end && __a == _Alloc())
|
||||||
|
return _S_empty_rep()._M_refcopy();
|
||||||
|
|
||||||
// NB: Not required, but considered best practice.
|
// NB: Not required, but considered best practice.
|
||||||
if (__builtin_expect(__beg == _InIter(), 0))
|
if (__builtin_expect(__beg == _InIter(), 0))
|
||||||
__throw_logic_error("attempt to create string with null pointer");
|
__throw_logic_error("attempt to create string with null pointer");
|
||||||
|
|
||||||
if (__beg == __end && __a == _Alloc())
|
|
||||||
return _S_empty_rep()._M_refcopy();
|
|
||||||
|
|
||||||
// Check for out_of_range and length_error exceptions.
|
// Check for out_of_range and length_error exceptions.
|
||||||
_Rep* __r = _Rep::_S_create(__dnew, __a);
|
_Rep* __r = _Rep::_S_create(__dnew, __a);
|
||||||
try
|
try
|
||||||
|
@ -223,8 +223,8 @@ namespace std
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc>
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
||||||
basic_string<_CharT, _Traits, _Alloc>::
|
basic_string<_CharT, _Traits, _Alloc>::
|
||||||
basic_string(const _CharT* __s, const _Alloc& __a)
|
basic_string(const _CharT* __s, const _Alloc& __a)
|
||||||
: _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) : 0,
|
: _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
|
||||||
__a), __a)
|
__s + npos, __a), __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc>
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
@ -214,6 +215,15 @@ void test04()
|
||||||
VERIFY( str02 == "onifotrop" );
|
VERIFY( str02 == "onifotrop" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// libstdc++/8347
|
||||||
|
void test05()
|
||||||
|
{
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
std::vector<char> empty;
|
||||||
|
std::string empty2(empty.begin(), empty.end());
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
__set_testsuite_memlimit();
|
__set_testsuite_memlimit();
|
||||||
|
@ -221,5 +231,6 @@ int main()
|
||||||
test02();
|
test02();
|
||||||
test03();
|
test03();
|
||||||
test04();
|
test04();
|
||||||
|
test05();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue