From: François Dumont Date: Wed, 4 Jul 2018 18:13:11 +0000 (+0000) Subject: re PR libstdc++/86272 (__gnu_debug::string uses undefined __glibcxx_check_insert_range2) X-Git-Tag: releases/gcc-9.1.0~5562 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96eb9df619ab1ba907c9dc6002f6bbc326e884fb;p=thirdparty%2Fgcc.git re PR libstdc++/86272 (__gnu_debug::string uses undefined __glibcxx_check_insert_range2) 2018-07-04 François Dumont 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 24acd68751b6..94db3f2ee170 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2018-07-03 François Dumont + + * 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 * testsuite/25_algorithms/make_heap/complexity.cc: Require effective diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index aa611b2d4a9b..ec4340c26e29 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -124,7 +124,7 @@ template, : _Base(__str, __pos, __n, __a) { } 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) { } basic_string(const _CharT* __s, const _Allocator& __a = _Allocator()) @@ -566,7 +566,7 @@ template, insert(const_iterator __p, _InputIterator __first, _InputIterator __last) { 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; if (__dist.second >= __dp_sign) diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc index 391528aa22e9..7ebbf60277ed 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc @@ -20,25 +20,32 @@ // 21.3.1 basic_string constructors. #include -#include #include #include +#ifdef _GLIBCXX_DEBUG +# include +using namespace __gnu_debug; +#else +# include +using namespace std; +#endif + void test01(void) { - typedef std::string::size_type csize_type; - typedef std::string::iterator citerator; - csize_type npos = std::string::npos; + typedef string::size_type csize_type; + typedef string::iterator citerator; + csize_type npos = string::npos; csize_type csz01; const char str_lit01[] = "rodeo beach, marin"; - const std::string str01(str_lit01); - const std::string str02("baker beach, san francisco"); + const string str01(str_lit01); + const string str02("baker beach, san francisco"); // basic_string(const string&, size_type pos = 0, siz_type n = npos, alloc) csz01 = str01.size(); try { - std::string str03(str01, csz01 + 1); + string str03(str01, csz01 + 1); VERIFY( false ); } catch(std::out_of_range& fail) { @@ -49,7 +56,7 @@ void test01(void) } try { - std::string str03(str01, csz01); + string str03(str01, csz01); VERIFY( str03.size() == 0 ); VERIFY( str03.size() <= str03.capacity() ); } @@ -62,7 +69,7 @@ void test01(void) // NB: As strlen(str_lit01) != csz01, this test is undefined. It // should not crash, but what gets constructed is a bit arbitrary. try { - std::string str03(str_lit01, csz01 + 1); + string str03(str_lit01, csz01 + 1); VERIFY( true ); } catch(std::length_error& fail) { @@ -76,7 +83,7 @@ void test01(void) // should not crash, but what gets constructed is a bit arbitrary. // The "maverick's" of all string objects. try { - std::string str04(str_lit01, npos); + string str04(str_lit01, npos); VERIFY( true ); } catch(std::length_error& fail) { @@ -88,7 +95,7 @@ void test01(void) // Build a maxsize - 1 lengthed string consisting of all A's try { - std::string str03(csz01 - 1, 'A'); + string str03(csz01 - 1, 'A'); VERIFY( str03.size() == csz01 - 1 ); VERIFY( str03.size() <= str03.capacity() ); } @@ -102,14 +109,14 @@ void test01(void) } // basic_string(const char* s, const allocator& a = allocator()) - std::string str04(str_lit01); + string str04(str_lit01); VERIFY( str01 == str04 ); // basic_string(size_type n, char c, const allocator& a = allocator()) csz01 = str01.max_size(); try { - std::string str03(csz01 + 1, 'z'); + string str03(csz01 + 1, 'z'); VERIFY( false ); } catch(std::length_error& fail) { @@ -120,7 +127,7 @@ void test01(void) } 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 ); } catch(std::length_error& fail) { @@ -131,7 +138,7 @@ void test01(void) } try { - std::string str03(csz01 - 1, 'z'); + string str03(csz01 - 1, 'z'); VERIFY( str03.size() != 0 ); VERIFY( str03.size() <= str03.capacity() ); } @@ -144,10 +151,9 @@ void test01(void) VERIFY( false ); } - // template // 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 ); } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc b/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc index 2cc9cffd34a0..aa7754821b9f 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc @@ -18,10 +18,15 @@ // { dg-do run { target c++11 } } -#include #include +#ifdef _GLIBCXX_DEBUG +#include +using namespace __gnu_debug; +#else +#include using namespace std; +#endif void test01(void) { diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc index 49e0af3a2ca9..eb180d36b58b 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc @@ -19,19 +19,26 @@ // 21.3.5.4 basic_string::insert -#include #include #include +#ifdef _GLIBCXX_DEBUG +#include +using namespace __gnu_debug; +#else +#include +using namespace std; +#endif + void test01(void) { - typedef std::string::size_type csize_type; - typedef std::string::iterator citerator; + typedef string::size_type csize_type; + typedef string::iterator citerator; csize_type csz01, csz02; - const std::string str01("rodeo beach, marin"); - const std::string str02("baker beach, san francisco"); - std::string str03; + const string str01("rodeo beach, marin"); + const string str02("baker beach, san francisco"); + string str03; // string& insert(size_type p1, const string& str, size_type p2, size_type n) // requires: @@ -76,7 +83,7 @@ void test01(void) csz01 = str01.max_size(); try { - std::string str04(csz01, 'b'); + string str04(csz01, 'b'); str03 = str04; csz02 = str02.size(); try { diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc index ff33dde0c84b..102e169e84f7 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc @@ -19,16 +19,23 @@ // 21.3.5.4 basic_string::insert -#include #include +#ifdef _GLIBCXX_DEBUG +#include +using namespace __gnu_debug; +#else +#include +using namespace std; +#endif + // More // string& insert(size_type __p, const char* s, size_type n); // string& insert(size_type __p, const char* s); // but now s points inside the _Rep void test02(void) { - std::string str01; + string str01; const char* title = "Everything was beautiful, and nothing hurt"; // Increasing size: str01 is reallocated every time. str01 = title; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/83328.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/83328.cc index 0480ce74531c..ef1d3a94d7ad 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/83328.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/83328.cc @@ -20,18 +20,25 @@ // PR libstdc++/83328 -#include #include +#ifdef _GLIBCXX_DEBUG +#include +using namespace __gnu_debug; +#else +#include +using namespace std; +#endif + void test01() { - std::string s = "insert"; + string s = "insert"; auto iter = s.insert(s.cbegin() + 2, std::initializer_list{}); VERIFY( iter == s.begin() + 2 ); iter = s.insert(s.cend(), { 'e', 'd' }); - std::string::iterator* check_type = &iter; + string::iterator* check_type = &iter; VERIFY( iter == s.cend() - 2 ); VERIFY( s == "inserted" ); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc index eb6e7654c8b8..1bc3d30cfb47 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc @@ -19,7 +19,13 @@ // { dg-do compile } -#include +#if _GLIBCXX_DEBUG +# include +using namespace __gnu_debug; +#else +# include +using namespace std; +#endif namespace N { @@ -36,7 +42,7 @@ namespace N int main() { - std::basic_string s(5, N::X()); + basic_string s(5, N::X()); s.erase(s.begin()); s.erase(s.begin(), s.end());