diff options
author | François Dumont <fdumont@gcc.gnu.org> | 2018-07-04 18:13:11 +0000 |
---|---|---|
committer | François Dumont <fdumont@gcc.gnu.org> | 2018-07-04 18:13:11 +0000 |
commit | 96eb9df619ab1ba907c9dc6002f6bbc326e884fb (patch) | |
tree | 7545255f80b50f3a2975c18b7d3f3c41b2b2d040 | |
parent | fa9371cae02b7ddee8f67e6ce8f1cddc3d8fc0e2 (diff) | |
download | gcc-96eb9df619ab1ba907c9dc6002f6bbc326e884fb.zip gcc-96eb9df619ab1ba907c9dc6002f6bbc326e884fb.tar.gz gcc-96eb9df619ab1ba907c9dc6002f6bbc326e884fb.tar.bz2 |
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
8 files changed, 85 insertions, 34 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 24acd68..94db3f2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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> * testsuite/25_algorithms/make_heap/complexity.cc: Require effective diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index aa611b2..ec4340c 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -124,7 +124,7 @@ template<typename _CharT, typename _Traits = std::char_traits<_CharT>, : _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<typename _CharT, typename _Traits = std::char_traits<_CharT>, 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 391528a..7ebbf60 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 <new> -#include <string> #include <stdexcept> #include <testsuite_hooks.h> +#ifdef _GLIBCXX_DEBUG +# include <debug/string> +using namespace __gnu_debug; +#else +# include <string> +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<typename _InputIter> // 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 2cc9cff..aa77548 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 <string> #include <testsuite_hooks.h> +#ifdef _GLIBCXX_DEBUG +#include <debug/string> +using namespace __gnu_debug; +#else +#include <string> 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 49e0af3..eb180d3 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 <string> #include <stdexcept> #include <testsuite_hooks.h> +#ifdef _GLIBCXX_DEBUG +#include <debug/string> +using namespace __gnu_debug; +#else +#include <string> +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 ff33dde..102e169 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 <string> #include <testsuite_hooks.h> +#ifdef _GLIBCXX_DEBUG +#include <debug/string> +using namespace __gnu_debug; +#else +#include <string> +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 0480ce7..ef1d3a9 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 <string> #include <testsuite_hooks.h> +#ifdef _GLIBCXX_DEBUG +#include <debug/string> +using namespace __gnu_debug; +#else +#include <string> +using namespace std; +#endif + void test01() { - std::string s = "insert"; + string s = "insert"; auto iter = s.insert(s.cbegin() + 2, std::initializer_list<char>{}); 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 eb6e765..1bc3d30 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 <string> +#if _GLIBCXX_DEBUG +# include <debug/string> +using namespace __gnu_debug; +#else +# include <string> +using namespace std; +#endif namespace N { @@ -36,7 +42,7 @@ namespace N 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.end()); |