mirror of git://gcc.gnu.org/git/gcc.git
re PR libstdc++/86272 (__gnu_debug::string uses undefined __glibcxx_check_insert_range2)
2018-07-04 François Dumont <fdumont@gcc.gnu.org> PR libstdc++/86272 * include/debug/string (__gnu_debug::basic_string<>::insert<_Ite>(const_iterator, _Ite, _Ite)): Use __glibcxx_check_insert_range. * 21_strings/basic_string/cons/char/1.cc: Adapt test to use __gnu_debug::string when _GLIBCXX_DEBUG. * 21_strings/basic_string/init-list.cc: Likewise. * 21_strings/basic_string/modifiers/insert/char/1.cc: Likewise. * 21_strings/basic_string/modifiers/insert/char/2.cc: Likewise. * 21_strings/basic_string/modifiers/insert/char/83328.cc: Likewise. * 21_strings/basic_string/types/1.cc: Likewise. From-SVN: r262417
This commit is contained in:
parent
fa9371cae0
commit
96eb9df619
|
|
@ -1,3 +1,16 @@
|
||||||
|
2018-07-03 François Dumont <fdumont@gcc.gnu.org>
|
||||||
|
|
||||||
|
* include/debug/string
|
||||||
|
(__gnu_debug::basic_string<>::insert<_Ite>(const_iterator, _Ite, _Ite)):
|
||||||
|
Use __glibcxx_check_insert_range.
|
||||||
|
* 21_strings/basic_string/cons/char/1.cc: Adapt test to use
|
||||||
|
__gnu_debug::string when _GLIBCXX_DEBUG.
|
||||||
|
* 21_strings/basic_string/init-list.cc: Likewise.
|
||||||
|
* 21_strings/basic_string/modifiers/insert/char/1.cc: Likewise.
|
||||||
|
* 21_strings/basic_string/modifiers/insert/char/2.cc: Likewise.
|
||||||
|
* 21_strings/basic_string/modifiers/insert/char/83328.cc: Likewise.
|
||||||
|
* 21_strings/basic_string/types/1.cc: Likewise.
|
||||||
|
|
||||||
2018-07-04 Jonathan Wakely <jwakely@redhat.com>
|
2018-07-04 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
* testsuite/25_algorithms/make_heap/complexity.cc: Require effective
|
* testsuite/25_algorithms/make_heap/complexity.cc: Require effective
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
|
||||||
: _Base(__str, __pos, __n, __a) { }
|
: _Base(__str, __pos, __n, __a) { }
|
||||||
|
|
||||||
basic_string(const _CharT* __s, size_type __n,
|
basic_string(const _CharT* __s, size_type __n,
|
||||||
const _Allocator& __a = _Allocator())
|
const _Allocator& __a = _Allocator())
|
||||||
: _Base(__gnu_debug::__check_string(__s, __n), __n, __a) { }
|
: _Base(__gnu_debug::__check_string(__s, __n), __n, __a) { }
|
||||||
|
|
||||||
basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
|
basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
|
||||||
|
|
@ -566,7 +566,7 @@ template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
|
||||||
insert(const_iterator __p, _InputIterator __first, _InputIterator __last)
|
insert(const_iterator __p, _InputIterator __first, _InputIterator __last)
|
||||||
{
|
{
|
||||||
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
|
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
|
||||||
__glibcxx_check_insert_range2(__p, __first, __last, __dist);
|
__glibcxx_check_insert_range(__p, __first, __last, __dist);
|
||||||
|
|
||||||
typename _Base::iterator __res;
|
typename _Base::iterator __res;
|
||||||
if (__dist.second >= __dp_sign)
|
if (__dist.second >= __dp_sign)
|
||||||
|
|
|
||||||
|
|
@ -20,25 +20,32 @@
|
||||||
// 21.3.1 basic_string constructors.
|
// 21.3.1 basic_string constructors.
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <string>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_DEBUG
|
||||||
|
# include <debug/string>
|
||||||
|
using namespace __gnu_debug;
|
||||||
|
#else
|
||||||
|
# include <string>
|
||||||
|
using namespace std;
|
||||||
|
#endif
|
||||||
|
|
||||||
void test01(void)
|
void test01(void)
|
||||||
{
|
{
|
||||||
typedef std::string::size_type csize_type;
|
typedef string::size_type csize_type;
|
||||||
typedef std::string::iterator citerator;
|
typedef string::iterator citerator;
|
||||||
csize_type npos = std::string::npos;
|
csize_type npos = string::npos;
|
||||||
csize_type csz01;
|
csize_type csz01;
|
||||||
|
|
||||||
const char str_lit01[] = "rodeo beach, marin";
|
const char str_lit01[] = "rodeo beach, marin";
|
||||||
const std::string str01(str_lit01);
|
const string str01(str_lit01);
|
||||||
const std::string str02("baker beach, san francisco");
|
const string str02("baker beach, san francisco");
|
||||||
|
|
||||||
// basic_string(const string&, size_type pos = 0, siz_type n = npos, alloc)
|
// basic_string(const string&, size_type pos = 0, siz_type n = npos, alloc)
|
||||||
csz01 = str01.size();
|
csz01 = str01.size();
|
||||||
try {
|
try {
|
||||||
std::string str03(str01, csz01 + 1);
|
string str03(str01, csz01 + 1);
|
||||||
VERIFY( false );
|
VERIFY( false );
|
||||||
}
|
}
|
||||||
catch(std::out_of_range& fail) {
|
catch(std::out_of_range& fail) {
|
||||||
|
|
@ -49,7 +56,7 @@ void test01(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::string str03(str01, csz01);
|
string str03(str01, csz01);
|
||||||
VERIFY( str03.size() == 0 );
|
VERIFY( str03.size() == 0 );
|
||||||
VERIFY( str03.size() <= str03.capacity() );
|
VERIFY( str03.size() <= str03.capacity() );
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +69,7 @@ void test01(void)
|
||||||
// NB: As strlen(str_lit01) != csz01, this test is undefined. It
|
// NB: As strlen(str_lit01) != csz01, this test is undefined. It
|
||||||
// should not crash, but what gets constructed is a bit arbitrary.
|
// should not crash, but what gets constructed is a bit arbitrary.
|
||||||
try {
|
try {
|
||||||
std::string str03(str_lit01, csz01 + 1);
|
string str03(str_lit01, csz01 + 1);
|
||||||
VERIFY( true );
|
VERIFY( true );
|
||||||
}
|
}
|
||||||
catch(std::length_error& fail) {
|
catch(std::length_error& fail) {
|
||||||
|
|
@ -76,7 +83,7 @@ void test01(void)
|
||||||
// should not crash, but what gets constructed is a bit arbitrary.
|
// should not crash, but what gets constructed is a bit arbitrary.
|
||||||
// The "maverick's" of all string objects.
|
// The "maverick's" of all string objects.
|
||||||
try {
|
try {
|
||||||
std::string str04(str_lit01, npos);
|
string str04(str_lit01, npos);
|
||||||
VERIFY( true );
|
VERIFY( true );
|
||||||
}
|
}
|
||||||
catch(std::length_error& fail) {
|
catch(std::length_error& fail) {
|
||||||
|
|
@ -88,7 +95,7 @@ void test01(void)
|
||||||
|
|
||||||
// Build a maxsize - 1 lengthed string consisting of all A's
|
// Build a maxsize - 1 lengthed string consisting of all A's
|
||||||
try {
|
try {
|
||||||
std::string str03(csz01 - 1, 'A');
|
string str03(csz01 - 1, 'A');
|
||||||
VERIFY( str03.size() == csz01 - 1 );
|
VERIFY( str03.size() == csz01 - 1 );
|
||||||
VERIFY( str03.size() <= str03.capacity() );
|
VERIFY( str03.size() <= str03.capacity() );
|
||||||
}
|
}
|
||||||
|
|
@ -102,14 +109,14 @@ void test01(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// basic_string(const char* s, const allocator& a = allocator())
|
// basic_string(const char* s, const allocator& a = allocator())
|
||||||
std::string str04(str_lit01);
|
string str04(str_lit01);
|
||||||
VERIFY( str01 == str04 );
|
VERIFY( str01 == str04 );
|
||||||
|
|
||||||
|
|
||||||
// basic_string(size_type n, char c, const allocator& a = allocator())
|
// basic_string(size_type n, char c, const allocator& a = allocator())
|
||||||
csz01 = str01.max_size();
|
csz01 = str01.max_size();
|
||||||
try {
|
try {
|
||||||
std::string str03(csz01 + 1, 'z');
|
string str03(csz01 + 1, 'z');
|
||||||
VERIFY( false );
|
VERIFY( false );
|
||||||
}
|
}
|
||||||
catch(std::length_error& fail) {
|
catch(std::length_error& fail) {
|
||||||
|
|
@ -120,7 +127,7 @@ void test01(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::string str04(npos, 'b'); // the "maverick's" of all string objects.
|
string str04(npos, 'b'); // the "maverick's" of all string objects.
|
||||||
VERIFY( false );
|
VERIFY( false );
|
||||||
}
|
}
|
||||||
catch(std::length_error& fail) {
|
catch(std::length_error& fail) {
|
||||||
|
|
@ -131,7 +138,7 @@ void test01(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::string str03(csz01 - 1, 'z');
|
string str03(csz01 - 1, 'z');
|
||||||
VERIFY( str03.size() != 0 );
|
VERIFY( str03.size() != 0 );
|
||||||
VERIFY( str03.size() <= str03.capacity() );
|
VERIFY( str03.size() <= str03.capacity() );
|
||||||
}
|
}
|
||||||
|
|
@ -144,10 +151,9 @@ void test01(void)
|
||||||
VERIFY( false );
|
VERIFY( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// template<typename _InputIter>
|
// template<typename _InputIter>
|
||||||
// basic_string(_InputIter begin, _InputIter end, const allocator& a)
|
// basic_string(_InputIter begin, _InputIter end, const allocator& a)
|
||||||
std::string str06(str01.begin(), str01.end());
|
string str06(str01.begin(), str01.end());
|
||||||
VERIFY( str06 == str01 );
|
VERIFY( str06 == str01 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,15 @@
|
||||||
|
|
||||||
// { dg-do run { target c++11 } }
|
// { dg-do run { target c++11 } }
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_DEBUG
|
||||||
|
#include <debug/string>
|
||||||
|
using namespace __gnu_debug;
|
||||||
|
#else
|
||||||
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#endif
|
||||||
|
|
||||||
void test01(void)
|
void test01(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,19 +19,26 @@
|
||||||
|
|
||||||
// 21.3.5.4 basic_string::insert
|
// 21.3.5.4 basic_string::insert
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_DEBUG
|
||||||
|
#include <debug/string>
|
||||||
|
using namespace __gnu_debug;
|
||||||
|
#else
|
||||||
|
#include <string>
|
||||||
|
using namespace std;
|
||||||
|
#endif
|
||||||
|
|
||||||
void test01(void)
|
void test01(void)
|
||||||
{
|
{
|
||||||
typedef std::string::size_type csize_type;
|
typedef string::size_type csize_type;
|
||||||
typedef std::string::iterator citerator;
|
typedef string::iterator citerator;
|
||||||
csize_type csz01, csz02;
|
csize_type csz01, csz02;
|
||||||
|
|
||||||
const std::string str01("rodeo beach, marin");
|
const string str01("rodeo beach, marin");
|
||||||
const std::string str02("baker beach, san francisco");
|
const string str02("baker beach, san francisco");
|
||||||
std::string str03;
|
string str03;
|
||||||
|
|
||||||
// string& insert(size_type p1, const string& str, size_type p2, size_type n)
|
// string& insert(size_type p1, const string& str, size_type p2, size_type n)
|
||||||
// requires:
|
// requires:
|
||||||
|
|
@ -76,7 +83,7 @@ void test01(void)
|
||||||
|
|
||||||
csz01 = str01.max_size();
|
csz01 = str01.max_size();
|
||||||
try {
|
try {
|
||||||
std::string str04(csz01, 'b');
|
string str04(csz01, 'b');
|
||||||
str03 = str04;
|
str03 = str04;
|
||||||
csz02 = str02.size();
|
csz02 = str02.size();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,23 @@
|
||||||
|
|
||||||
// 21.3.5.4 basic_string::insert
|
// 21.3.5.4 basic_string::insert
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_DEBUG
|
||||||
|
#include <debug/string>
|
||||||
|
using namespace __gnu_debug;
|
||||||
|
#else
|
||||||
|
#include <string>
|
||||||
|
using namespace std;
|
||||||
|
#endif
|
||||||
|
|
||||||
// More
|
// More
|
||||||
// string& insert(size_type __p, const char* s, size_type n);
|
// string& insert(size_type __p, const char* s, size_type n);
|
||||||
// string& insert(size_type __p, const char* s);
|
// string& insert(size_type __p, const char* s);
|
||||||
// but now s points inside the _Rep
|
// but now s points inside the _Rep
|
||||||
void test02(void)
|
void test02(void)
|
||||||
{
|
{
|
||||||
std::string str01;
|
string str01;
|
||||||
const char* title = "Everything was beautiful, and nothing hurt";
|
const char* title = "Everything was beautiful, and nothing hurt";
|
||||||
// Increasing size: str01 is reallocated every time.
|
// Increasing size: str01 is reallocated every time.
|
||||||
str01 = title;
|
str01 = title;
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,25 @@
|
||||||
|
|
||||||
// PR libstdc++/83328
|
// PR libstdc++/83328
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_DEBUG
|
||||||
|
#include <debug/string>
|
||||||
|
using namespace __gnu_debug;
|
||||||
|
#else
|
||||||
|
#include <string>
|
||||||
|
using namespace std;
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
test01()
|
test01()
|
||||||
{
|
{
|
||||||
std::string s = "insert";
|
string s = "insert";
|
||||||
auto iter = s.insert(s.cbegin() + 2, std::initializer_list<char>{});
|
auto iter = s.insert(s.cbegin() + 2, std::initializer_list<char>{});
|
||||||
VERIFY( iter == s.begin() + 2 );
|
VERIFY( iter == s.begin() + 2 );
|
||||||
|
|
||||||
iter = s.insert(s.cend(), { 'e', 'd' });
|
iter = s.insert(s.cend(), { 'e', 'd' });
|
||||||
std::string::iterator* check_type = &iter;
|
string::iterator* check_type = &iter;
|
||||||
VERIFY( iter == s.cend() - 2 );
|
VERIFY( iter == s.cend() - 2 );
|
||||||
VERIFY( s == "inserted" );
|
VERIFY( s == "inserted" );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,13 @@
|
||||||
|
|
||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
|
|
||||||
#include <string>
|
#if _GLIBCXX_DEBUG
|
||||||
|
# include <debug/string>
|
||||||
|
using namespace __gnu_debug;
|
||||||
|
#else
|
||||||
|
# include <string>
|
||||||
|
using namespace std;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace N
|
namespace N
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +42,7 @@ namespace N
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::basic_string<N::X> s(5, N::X());
|
basic_string<N::X> s(5, N::X());
|
||||||
|
|
||||||
s.erase(s.begin());
|
s.erase(s.begin());
|
||||||
s.erase(s.begin(), s.end());
|
s.erase(s.begin(), s.end());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue