Greetings,

I've finished backport of r202818 from trunk to google/gcc-4_8 as r206071.

Thanks,
-- 
Paul Pluzhnikov
Index: libstdc++-v3/include/debug/array
===================================================================
--- libstdc++-v3/include/debug/array    (revision 206038)
+++ libstdc++-v3/include/debug/array    (working copy)
@@ -165,7 +165,10 @@
       at(size_type __n)
       {
        if (__n >= _Nm)
-         std::__throw_out_of_range(__N("array::at"));
+         std::__throw_out_of_range_fmt(__N("array::at: __n "
+                                           "(which is %zu) >= _Nm "
+                                           "(which is %zu)"),
+                                       __n, _Nm);
        return _AT_Type::_S_ref(_M_elems, __n);
       }
 
@@ -175,7 +178,9 @@
        // Result of conditional expression must be an lvalue so use
        // boolean ? lvalue : (throw-expr, lvalue)
        return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
-         : (std::__throw_out_of_range(__N("array::at")),
+         : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+                                              ">= _Nm (which is %zu)"),
+                                          __n, _Nm),
             _AT_Type::_S_ref(_M_elems, 0));
       }
 
Index: libstdc++-v3/include/std/bitset
===================================================================
--- libstdc++-v3/include/std/bitset     (revision 206038)
+++ libstdc++-v3/include/std/bitset     (working copy)
@@ -752,7 +752,27 @@
       typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
       typedef unsigned long _WordT;
 
+      template<class _CharT, class _Traits, class _Alloc>
       void
+      _M_check_initial_position(const std::basic_string<_CharT, _Traits, 
_Alloc>& __s,
+                               size_t __position) const
+      {
+       if (__position > __s.size())
+         __throw_out_of_range_fmt(__N("bitset::bitset: __position "
+                                      "(which is %zu) > __s.size() "
+                                      "(which is %zu)"),
+                                  __position, __s.size());
+      }
+
+      void _M_check(size_t __position, const char *__s) const
+      {
+       if (__position >= _Nb)
+         __throw_out_of_range_fmt(__N("%s: __position (which is %zu) "
+                                      ">= _Nb (which is %zu)"),
+                                  __s, __position, _Nb);
+      }
+
+      void
       _M_do_sanitize() _GLIBCXX_NOEXCEPT
       { 
        typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type;
@@ -867,9 +887,7 @@
               size_t __position = 0)
        : _Base()
        {
-         if (__position > __s.size())
-           __throw_out_of_range(__N("bitset::bitset initial position "
-                                    "not valid"));
+         _M_check_initial_position(__s, __position);
          _M_copy_from_string(__s, __position,
                              std::basic_string<_CharT, _Traits, _Alloc>::npos,
                              _CharT('0'), _CharT('1'));
@@ -890,9 +908,7 @@
               size_t __position, size_t __n)
        : _Base()
        {
-         if (__position > __s.size())
-           __throw_out_of_range(__N("bitset::bitset initial position "
-                                    "not valid"));
+         _M_check_initial_position(__s, __position);
          _M_copy_from_string(__s, __position, __n, _CharT('0'), _CharT('1'));
        }
 
@@ -904,9 +920,7 @@
               _CharT __zero, _CharT __one = _CharT('1'))
        : _Base()
        {
-         if (__position > __s.size())
-           __throw_out_of_range(__N("bitset::bitset initial position "
-                                    "not valid"));
+         _M_check_initial_position(__s, __position);
          _M_copy_from_string(__s, __position, __n, __zero, __one);
        }
 
@@ -1067,8 +1081,7 @@
       bitset<_Nb>&
       set(size_t __position, bool __val = true)
       {
-       if (__position >= _Nb)
-         __throw_out_of_range(__N("bitset::set"));
+       this->_M_check(__position, __N("bitset::set"));
        return _Unchecked_set(__position, __val);
       }
 
@@ -1092,8 +1105,7 @@
       bitset<_Nb>&
       reset(size_t __position)
       {
-       if (__position >= _Nb)
-         __throw_out_of_range(__N("bitset::reset"));
+       this->_M_check(__position, __N("bitset::reset"));
        return _Unchecked_reset(__position);
       }
       
@@ -1116,8 +1128,7 @@
       bitset<_Nb>&
       flip(size_t __position)
       {
-       if (__position >= _Nb)
-         __throw_out_of_range(__N("bitset::flip"));
+       this->_M_check(__position, __N("bitset::flip"));
        return _Unchecked_flip(__position);
       }
       
@@ -1302,8 +1313,7 @@
       bool
       test(size_t __position) const
       {
-       if (__position >= _Nb)
-         __throw_out_of_range(__N("bitset::test"));
+       this->_M_check(__position, __N("bitset::test"));
        return _Unchecked_test(__position);
       }
 
Index: libstdc++-v3/include/std/array
===================================================================
--- libstdc++-v3/include/std/array      (revision 206038)
+++ libstdc++-v3/include/std/array      (working copy)
@@ -180,7 +180,9 @@
       at(size_type __n)
       {
        if (__n >= _Nm)
-         std::__throw_out_of_range(__N("array::at"));
+         std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+                                           ">= _Nm (which is %zu)"),
+                                       __n, _Nm);
        return _AT_Type::_S_ref(_M_elems, __n);
       }
 
@@ -190,7 +192,9 @@
        // Result of conditional expression must be an lvalue so use
        // boolean ? lvalue : (throw-expr, lvalue)
        return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
-         : (std::__throw_out_of_range(__N("array::at")),
+         : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+                                              ">= _Nm (which is %zu)"),
+                                          __n, _Nm),
             _AT_Type::_S_ref(_M_elems, 0));
       }
 
Index: libstdc++-v3/include/ext/vstring.h
===================================================================
--- libstdc++-v3/include/ext/vstring.h  (revision 206038)
+++ libstdc++-v3/include/ext/vstring.h  (working copy)
@@ -100,7 +100,9 @@
       _M_check(size_type __pos, const char* __s) const
       {
        if (__pos > this->size())
-         std::__throw_out_of_range(__N(__s));
+         std::__throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
+                                           "this->size() (which is %zu)"),
+                                       __s, __pos, this->size());
        return __pos;
       }
 
@@ -596,7 +598,10 @@
       at(size_type __n) const
       {
        if (__n >= this->size())
-         std::__throw_out_of_range(__N("__versa_string::at"));
+         std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
+                                           "(which is %zu) >= this->size() "
+                                           "(which is %zu)"),
+                                       __n, this->size());
        return this->_M_data()[__n];
       }
 
@@ -615,7 +620,10 @@
       at(size_type __n)
       {
        if (__n >= this->size())
-         std::__throw_out_of_range(__N("__versa_string::at"));
+         std::__throw_out_of_range_fmt(__N("__versa_string::at: __n "
+                                           "(which is %zu) >= this->size() "
+                                           "(which is %zu)"),
+                                       __n, this->size());
        this->_M_leak();
        return this->_M_data()[__n];
       }
Index: libstdc++-v3/include/profile/array
===================================================================
--- libstdc++-v3/include/profile/array  (revision 206038)
+++ libstdc++-v3/include/profile/array  (working copy)
@@ -138,7 +138,10 @@
       at(size_type __n)
       {
        if (__n >= _Nm)
-         std::__throw_out_of_range(__N("array::at"));
+         std::__throw_out_of_range_fmt(__N("array::at: __n "
+                                           "(which is %zu) >= _Nm "
+                                           "(which is %zu)"),
+                                       __n, _Nm);
        return _AT_Type::_S_ref(_M_elems, __n);
       }
 
@@ -148,7 +151,9 @@
        // Result of conditional expression must be an lvalue so use
        // boolean ? lvalue : (throw-expr, lvalue)
        return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
-         : (std::__throw_out_of_range(__N("array::at")),
+         : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+                                              ">= _Nm (which is %zu)"),
+                                          __n, _Nm),
             _AT_Type::_S_ref(_M_elems, 0));
       }
 
Index: libstdc++-v3/include/bits/stl_deque.h
===================================================================
--- libstdc++-v3/include/bits/stl_deque.h       (revision 206038)
+++ libstdc++-v3/include/bits/stl_deque.h       (working copy)
@@ -1275,7 +1275,10 @@
       _M_range_check(size_type __n) const
       {
        if (__n >= this->size())
-         __throw_out_of_range(__N("deque::_M_range_check"));
+         __throw_out_of_range_fmt(__N("deque::_M_range_check: __n "
+                                      "(which is %zu)>= this->size() "
+                                      "(which is %zu)"),
+                                  __n, this->size());
       }
 
     public:
Index: libstdc++-v3/include/bits/stl_bvector.h
===================================================================
--- libstdc++-v3/include/bits/stl_bvector.h     (revision 206038)
+++ libstdc++-v3/include/bits/stl_bvector.h     (working copy)
@@ -867,7 +867,10 @@
     _M_range_check(size_type __n) const
     {
       if (__n >= this->size())
-        __throw_out_of_range(__N("vector<bool>::_M_range_check"));
+       __throw_out_of_range_fmt(__N("vector<bool>::_M_range_check: __n "
+                                    "(which is %zu) >= this->size() "
+                                    "(which is %zu)"),
+                                __n, this->size());
     }
 
   public:
Index: libstdc++-v3/include/bits/basic_string.h
===================================================================
--- libstdc++-v3/include/bits/basic_string.h    (revision 206038)
+++ libstdc++-v3/include/bits/basic_string.h    (working copy)
@@ -321,7 +321,9 @@
       _M_check(size_type __pos, const char* __s) const
       {
        if (__pos > this->size())
-         __throw_out_of_range(__N(__s));
+         __throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
+                                      "this->size() (which is %zu)"),
+                                  __s, __pos, this->size());
        return __pos;
       }
 
@@ -865,7 +867,10 @@
       at(size_type __n) const
       {
        if (__n >= this->size())
-         __throw_out_of_range(__N("basic_string::at"));
+         __throw_out_of_range_fmt(__N("basic_string::at: __n "
+                                      "(which is %zu) >= this->size() "
+                                      "(which is %zu)"),
+                                  __n, this->size());
        return _M_data()[__n];
       }
 
@@ -884,7 +889,10 @@
       at(size_type __n)
       {
        if (__n >= size())
-         __throw_out_of_range(__N("basic_string::at"));
+         __throw_out_of_range_fmt(__N("basic_string::at: __n "
+                                      "(which is %zu) >= this->size() "
+                                      "(which is %zu)"),
+                                  __n, this->size());
        _M_leak();
        return _M_data()[__n];
       }
Index: libstdc++-v3/include/bits/stl_vector.h
===================================================================
--- libstdc++-v3/include/bits/stl_vector.h      (revision 206038)
+++ libstdc++-v3/include/bits/stl_vector.h      (working copy)
@@ -872,7 +872,10 @@
       _M_range_check(size_type __n) const
       {
        if (__n >= this->size())
-         __throw_out_of_range(__N("vector::_M_range_check"));
+         __throw_out_of_range_fmt(__N("vector::_M_range_check: __n "
+                                      "(which is %zu) >= this->size() "
+                                      "(which is %zu)"),
+                                  __n, this->size());
       }
 
     public:
Index: libstdc++-v3/include/bits/functexcept.h
===================================================================
--- libstdc++-v3/include/bits/functexcept.h     (revision 206038)
+++ libstdc++-v3/include/bits/functexcept.h     (working copy)
@@ -75,6 +75,10 @@
   __throw_out_of_range(const char*) __attribute__((__noreturn__));
 
   void
+  __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__))
+    __attribute__((__format__(__printf__, 1, 2)));
+
+  void
   __throw_runtime_error(const char*) __attribute__((__noreturn__));
 
   void
Index: libstdc++-v3/testsuite/util/exception/safety.h
===================================================================
--- libstdc++-v3/testsuite/util/exception/safety.h      (revision 206038)
+++ libstdc++-v3/testsuite/util/exception/safety.h      (working copy)
@@ -47,22 +47,12 @@
       const typename distribution_type::param_type p(0, __max_size);
       size_type random = generator(p);
       if (random < distribution.min() || random > distribution.max())
-       {
-         std::string __s("setup_base::generate");
-         __s += "\n";
-         __s += "random number generated is: ";
-         char buf[40];
-         __builtin_sprintf(buf, "%lu", (unsigned long)random);
-         __s += buf;
-         __s += " on range [";
-         __builtin_sprintf(buf, "%lu", (unsigned long)distribution.min());
-         __s += buf;
-         __s += ", ";
-         __builtin_sprintf(buf, "%lu", (unsigned long)distribution.max());
-         __s += buf;
-         __s += "]\n";
-         std::__throw_out_of_range(__s.c_str());
-       }
+       std::__throw_out_of_range_fmt(__N("setup_base::generate\n"
+                                         "random number generated is: %zu "
+                                         "out of range [%zu, %zu]\n"),
+                                     (size_t)random,
+                                     (size_t)distribution.min(),
+                                     (size_t)distribution.max());
       return random;
     }
 
Index: libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
===================================================================
--- libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc       
(revision 206038)
+++ libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc       
(working copy)
@@ -28,6 +28,6 @@
 int n2 = std::get<1>(std::move(a));
 int n3 = std::get<1>(ca);
 
-// { dg-error "static assertion failed" "" { target *-*-* } 270 }
-// { dg-error "static assertion failed" "" { target *-*-* } 279 }
-// { dg-error "static assertion failed" "" { target *-*-* } 287 }
+// { dg-error "static assertion failed" "" { target *-*-* } 274 }
+// { dg-error "static assertion failed" "" { target *-*-* } 283 }
+// { dg-error "static assertion failed" "" { target *-*-* } 291 }
Index: 
libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
===================================================================
--- 
libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc 
    (revision 206038)
+++ 
libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc 
    (working copy)
@@ -23,4 +23,4 @@
 
 typedef std::tuple_element<1, std::array<int, 1>>::type type;
 
-// { dg-error "static assertion failed" "" { target *-*-* } 316 }
+// { dg-error "static assertion failed" "" { target *-*-* } 320 }
Index: 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
===================================================================
--- 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc    
    (revision 206038)
+++ 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc    
    (working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1361 }
+// { dg-error "no matching" "" { target *-*-* } 1364 }
 
 #include <vector>
 
Index: 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
===================================================================
--- 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc    
    (revision 206038)
+++ 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc    
    (working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1402 }
+// { dg-error "no matching" "" { target *-*-* } 1405 }
 
 #include <vector>
 
Index: 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
===================================================================
--- 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
 (revision 206038)
+++ 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
 (working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1287 }
+// { dg-error "no matching" "" { target *-*-* } 1290 }
 
 #include <vector>
 
Index: 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
===================================================================
--- 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
 (revision 206038)
+++ 
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
 (working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1287 }
+// { dg-error "no matching" "" { target *-*-* } 1290 }
 
 #include <vector>
 #include <utility>
Index: 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
===================================================================
--- libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc 
(revision 206038)
+++ libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc 
(working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1730 }
+// { dg-error "no matching" "" { target *-*-* } 1733 }
 
 #include <deque>
 
Index: 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
===================================================================
--- libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc 
(revision 206038)
+++ libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc 
(working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1814 }
+// { dg-error "no matching" "" { target *-*-* } 1817 }
 
 #include <deque>
 
Index: 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
===================================================================
--- 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
  (revision 206038)
+++ 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
  (working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1663 }
+// { dg-error "no matching" "" { target *-*-* } 1666 }
 
 #include <deque>
 
Index: 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
===================================================================
--- 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
  (revision 206038)
+++ 
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
  (working copy)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1663 }
+// { dg-error "no matching" "" { target *-*-* } 1666 }
 
 #include <deque>
 #include <utility>

Reply via email to