]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/86272 (__gnu_debug::string uses undefined __glibcxx_check_insert_range2)
authorFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 4 Jul 2018 18:13:11 +0000 (18:13 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 4 Jul 2018 18:13:11 +0000 (18:13 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/debug/string
libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc
libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc
libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc
libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc
libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/83328.cc
libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc

index 24acd68751b63a6f85bbece789ab1b55efd88879..94db3f2ee170ccda9d851b2afba3954d13e5ded2 100644 (file)
@@ -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
index aa611b2d4a9b7c5bd6076b15b7b76d57feb497e1..ec4340c26e2979d73dce41f9ac44bf832e06b163 100644 (file)
@@ -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)
index 391528aa22e987839c1295594524946741b2bbeb..7ebbf60277edd7828036aa1e1781246f73def29b 100644 (file)
 // 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 );
 }
 
index 2cc9cffd34a0f29afd361cdcd08d48a6d35ad33f..aa7754821b9f127a8d3f9f28c1a124d5e65dfe1d 100644 (file)
 
 // { 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)
 {
index 49e0af3a2ca96730a51a30adb801fe08320a5f09..eb180d36b58b5e0338623b3a40ff7166b16c4269 100644 (file)
 
 // 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 {
index ff33dde0c84b8a9b2bded9443e167f0cdf525f96..102e169e84f73b672f4524fe86edbd6fe471e708 100644 (file)
 
 // 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;
index 0480ce74531c2b6bbf91b72d8841c0fc7aa2ee1d..ef1d3a94d7ad69845e23e09b6c1eb320d6466e92 100644 (file)
 
 // 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" );
 
index eb6e7654c8b87e40941f9b86a1a8e80be0c3557b..1bc3d30cfb47584dc5fc8eab64e7cbbf21012a0c 100644 (file)
 
 // { 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());