Patchwork [v3] Declare std::hash specializations noexcept

login
register
mail settings
Submitter Paolo Carlini
Date Nov. 18, 2011, 12:39 p.m.
Message ID <4EC65201.7010209@oracle.com>
Download mbox | patch
Permalink /patch/126406/
State New
Headers show

Comments

Paolo Carlini - Nov. 18, 2011, 12:39 p.m.
Hi,

this makes sure the various hash specializations are declared noexcept. 
Francois, please let me know if you are seeing something wrong / missing 
as part of your work...

Tested x86_64-linux, committed.

Thanks,
Paolo.

//////////////////////
2011-11-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* src/hash-long-double-aux.cc: Rename to...
	* src/hash-long-double-tr1-aux.cc: ... this.
	* src/compatibility-ldbl.cc: Adjust.
	* src/hash_tr1.cc: Likewise.
	* src/hash_c++0x.cc: Don't use src/hash-long-double-aux.cc.
	* include/bits/functional_hash.h (hash<_Tp*>::operator(), specs
	for integer types, hash<float>::operator(), hash<double>::operator(),
	hash<long double>::operator()): Declare noexcept.
	* include/debug/bitset (hash<__debug::bitset>::operator()): Likewise.
	* include/debug/vector (hash<__debug::vector>::operator()): Likewise.
	* include/std/system_error (hash<error_code>::operator()): Likewise.
	* include/std/thread (hash<thread::id>::operator()): Likewise.
	* include/std/bitset (hash<bitset>::operator()): Likewise.
	* include/std/typeindex (hash<type_index>::operator()): Likewise.
	* include/profile/bitset (hash<__profile::vector>::operator()):
	Likewise.
	* include/profile/vector (hash<__profile::vector>::operator()):
	Likewise.
	* include/ext/vstring.h (hash<__vstring>::operator(),
	hash<__wvstring>::operator(), hash<__u16vstring>::operator(),
	hash<__u32vstring>::operator()): Likewise.
	* include/bits/shared_ptr.h (hash<shared_ptr>::operator()): Likewise.
	* include/bits/shared_ptr_base.h (hash<__shared_ptr>::operator()):
	Likewise.
	* include/bits/unique_ptr.h (hash<unique_ptr>::operator()): Likewise.
	* include/bits/basic_string.h (hash<string>::operator(),
	hash<wstring>::operator(), hash<u16string>::operator(),
	hash<u32string>::operator()): Likewise.
	* include/bits/vector.tcc (hash<vector>::operator()): Likewise.
	* include/bits/stl_bvector.h (hash<vector>::operator()): Likewise.
	* libsupc++/typeinfo (type_info::hash_code): Use noexcept instead of
	throw().

Patch

Index: src/hash_c++0x.cc
===================================================================
--- src/hash_c++0x.cc	(revision 181470)
+++ src/hash_c++0x.cc	(working copy)
@@ -1,6 +1,6 @@ 
 // std::hash definitions -*- C++ -*-
 
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -30,5 +30,27 @@ 
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-#include "hash-long-double-aux.cc"
+  _GLIBCXX_PURE size_t
+  hash<long double>::operator()(long double __val) const noexcept
+  {
+    // 0 and -0 both hash to zero.
+    if (__val == 0.0L)
+      return 0;
+
+    int __exponent;
+    __val = __builtin_frexpl(__val, &__exponent);
+    __val = __val < 0.0l ? -(__val + 0.5l) : __val;
+
+    const long double __mult = __SIZE_MAX__ + 1.0l;
+    __val *= __mult;
+
+    // Try to use all the bits of the mantissa (really necessary only
+    // on 32-bit targets, at least for 80-bit floating point formats).
+    const size_t __hibits = (size_t)__val;
+    __val = (__val - (long double)__hibits) * __mult;
+
+    const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
+
+    return __hibits + (size_t)__val + __coeff * __exponent;
+  }
 }
Index: src/compatibility-ldbl.cc
===================================================================
--- src/compatibility-ldbl.cc	(revision 181470)
+++ src/compatibility-ldbl.cc	(working copy)
@@ -1,6 +1,6 @@ 
 // Compatibility symbols for -mlong-double-64 compatibility -*- C++ -*-
 
-// Copyright (C) 2006, 2008, 2009, 2010
+// Copyright (C) 2006, 2008, 2009, 2010, 2011
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -69,15 +69,8 @@ 
 
 // For std::tr1::hash<long double>::operator()
 #define _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
+#include "hash-long-double-tr1-aux.cc"
 
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-  namespace tr1 
-  {
-#include "hash-long-double-aux.cc"
-  }
-}
-
 // std::tr1::hash<long double>::operator()
 // and std::hash<long double>::operator()
 // are the same, no need to duplicate them.
Index: src/hash_tr1.cc
===================================================================
--- src/hash_tr1.cc	(revision 181470)
+++ src/hash_tr1.cc	(working copy)
@@ -1,6 +1,6 @@ 
 // std::tr1::hash definitions -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -25,12 +25,12 @@ 
 #include <string>
 #include <tr1/functional>
 
+#include "hash-long-double-tr1-aux.cc"
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   namespace tr1 
   {
-#include "hash-long-double-aux.cc"
-
 #ifndef _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
   template<>
     size_t
Index: src/hash-long-double-tr1-aux.cc
===================================================================
--- src/hash-long-double-tr1-aux.cc	(revision 181470)
+++ src/hash-long-double-tr1-aux.cc	(working copy)
@@ -1,6 +1,6 @@ 
-//  std::hash and std::tr1::hash definitions, long double bits -*- C++ -*-
+// std::tr1::hash definitions, long double bits -*- C++ -*-
 
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -22,29 +22,35 @@ 
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
-  // For long double, careful with random padding bits (e.g., on x86,
-  // 10 bytes -> 12 bytes) and resort to frexp.
-  template<>
-    size_t
-    hash<long double>::operator()(long double __val) const
-    {
-      // 0 and -0 both hash to zero.
-      if (__val == 0.0L)
-	return 0;
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+  namespace tr1 
+  {
+    // For long double, careful with random padding bits (e.g., on x86,
+    // 10 bytes -> 12 bytes) and resort to frexp.
+    template<>
+      size_t
+      hash<long double>::operator()(long double __val) const
+      {
+	// 0 and -0 both hash to zero.
+	if (__val == 0.0L)
+	  return 0;
 
-      int __exponent;
-      __val = __builtin_frexpl(__val, &__exponent);
-      __val = __val < 0.0l ? -(__val + 0.5l) : __val;
+	int __exponent;
+	__val = __builtin_frexpl(__val, &__exponent);
+	__val = __val < 0.0l ? -(__val + 0.5l) : __val;
 
-      const long double __mult = __SIZE_MAX__ + 1.0l;
-      __val *= __mult;
+	const long double __mult = __SIZE_MAX__ + 1.0l;
+	__val *= __mult;
 
-      // Try to use all the bits of the mantissa (really necessary only
-      // on 32-bit targets, at least for 80-bit floating point formats).
-      const size_t __hibits = (size_t)__val;
-      __val = (__val - (long double)__hibits) * __mult;
+	// Try to use all the bits of the mantissa (really necessary only
+	// on 32-bit targets, at least for 80-bit floating point formats).
+	const size_t __hibits = (size_t)__val;
+	__val = (__val - (long double)__hibits) * __mult;
 
-      const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
+	const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
 
-      return __hibits + (size_t)__val + __coeff * __exponent;
-    }
+	return __hibits + (size_t)__val + __coeff * __exponent;
+      }
+  }
+}
Index: src/hash-long-double-aux.cc
===================================================================
--- src/hash-long-double-aux.cc	(revision 181470)
+++ src/hash-long-double-aux.cc	(working copy)
@@ -1,50 +0,0 @@ 
-//  std::hash and std::tr1::hash definitions, long double bits -*- C++ -*-
-
-// Copyright (C) 2010 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// Under Section 7 of GPL version 3, you are granted additional
-// permissions described in the GCC Runtime Library Exception, version
-// 3.1, as published by the Free Software Foundation.
-
-// You should have received a copy of the GNU General Public License and
-// a copy of the GCC Runtime Library Exception along with this program;
-// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-// <http://www.gnu.org/licenses/>.
-
-  // For long double, careful with random padding bits (e.g., on x86,
-  // 10 bytes -> 12 bytes) and resort to frexp.
-  template<>
-    size_t
-    hash<long double>::operator()(long double __val) const
-    {
-      // 0 and -0 both hash to zero.
-      if (__val == 0.0L)
-	return 0;
-
-      int __exponent;
-      __val = __builtin_frexpl(__val, &__exponent);
-      __val = __val < 0.0l ? -(__val + 0.5l) : __val;
-
-      const long double __mult = __SIZE_MAX__ + 1.0l;
-      __val *= __mult;
-
-      // Try to use all the bits of the mantissa (really necessary only
-      // on 32-bit targets, at least for 80-bit floating point formats).
-      const size_t __hibits = (size_t)__val;
-      __val = (__val - (long double)__hibits) * __mult;
-
-      const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
-
-      return __hibits + (size_t)__val + __coeff * __exponent;
-    }
Index: include/debug/bitset
===================================================================
--- include/debug/bitset	(revision 181470)
+++ include/debug/bitset	(working copy)
@@ -414,7 +414,7 @@ 
     : public __hash_base<size_t, __debug::bitset<_Nb>>
     {
       size_t
-      operator()(const __debug::bitset<_Nb>& __b) const
+      operator()(const __debug::bitset<_Nb>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); }
     };
 #endif
Index: include/debug/vector
===================================================================
--- include/debug/vector	(revision 181470)
+++ include/debug/vector	(working copy)
@@ -625,7 +625,7 @@ 
     : public __hash_base<size_t, __debug::vector<bool, _Alloc>>
     {
       size_t
-      operator()(const __debug::vector<bool, _Alloc>& __b) const
+      operator()(const __debug::vector<bool, _Alloc>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()
 	  (__b._M_base()); }
     };
Index: include/std/system_error
===================================================================
--- include/std/system_error	(revision 181470)
+++ include/std/system_error	(working copy)
@@ -361,7 +361,7 @@ 
     : public __hash_base<size_t, error_code>
     {
       size_t
-      operator()(const error_code& __e) const
+      operator()(const error_code& __e) const noexcept
       {
 	const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
 	return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
Index: include/std/thread
===================================================================
--- include/std/thread	(revision 181470)
+++ include/std/thread	(working copy)
@@ -221,7 +221,7 @@ 
     : public __hash_base<size_t, thread::id>
     {
       size_t
-      operator()(const thread::id& __id) const
+      operator()(const thread::id& __id) const noexcept
       { return std::_Hash_impl::hash(__id._M_thread); }
     };
 
Index: include/std/bitset
===================================================================
--- include/std/bitset	(revision 181470)
+++ include/std/bitset	(working copy)
@@ -1555,7 +1555,7 @@ 
     : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<_Nb>>
     {
       size_t
-      operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const
+      operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept
       {
 	const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__;
 	return std::_Hash_impl::hash(__b._M_getdata(), __clength);
@@ -1567,7 +1567,7 @@ 
     : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<0>>
     {
       size_t
-      operator()(const _GLIBCXX_STD_C::bitset<0>&) const
+      operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept
       { return 0; }
     };
 
Index: include/std/typeindex
===================================================================
--- include/std/typeindex	(revision 181470)
+++ include/std/typeindex	(working copy)
@@ -76,7 +76,7 @@ 
     { return !_M_target->before(*__rhs._M_target); }
 
     size_t
-    hash_code() const
+    hash_code() const noexcept
     { return _M_target->hash_code(); }
 
     const char*
@@ -97,7 +97,7 @@ 
       typedef type_index  argument_type;
 
       size_t
-      operator()(const type_index& __ti) const
+      operator()(const type_index& __ti) const noexcept
       { return __ti.hash_code(); }
     };
 
Index: include/ext/vstring.h
===================================================================
--- include/ext/vstring.h	(revision 181470)
+++ include/ext/vstring.h	(working copy)
@@ -2769,7 +2769,7 @@ 
     : public __hash_base<size_t, __gnu_cxx::__vstring>
     {
       size_t
-      operator()(const __gnu_cxx::__vstring& __s) const
+      operator()(const __gnu_cxx::__vstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(), __s.length()); }
     };
 
@@ -2780,7 +2780,7 @@ 
     : public __hash_base<size_t, __gnu_cxx::__wvstring>
     {
       size_t
-      operator()(const __gnu_cxx::__wvstring& __s) const
+      operator()(const __gnu_cxx::__wvstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(wchar_t)); }
     };
@@ -2793,7 +2793,7 @@ 
     : public __hash_base<size_t, __gnu_cxx::__u16vstring>
     {
       size_t
-      operator()(const __gnu_cxx::__u16vstring& __s) const
+      operator()(const __gnu_cxx::__u16vstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char16_t)); }
     };
@@ -2804,7 +2804,7 @@ 
     : public __hash_base<size_t, __gnu_cxx::__u32vstring>
     {
       size_t
-      operator()(const __gnu_cxx::__u32vstring& __s) const
+      operator()(const __gnu_cxx::__u32vstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char32_t)); }
     };
Index: include/profile/bitset
===================================================================
--- include/profile/bitset	(revision 181470)
+++ include/profile/bitset	(working copy)
@@ -372,7 +372,7 @@ 
     : public __hash_base<size_t, __profile::bitset<_Nb>>
     {
       size_t
-      operator()(const __profile::bitset<_Nb>& __b) const
+      operator()(const __profile::bitset<_Nb>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); }
     };
 #endif
Index: include/profile/vector
===================================================================
--- include/profile/vector	(revision 181470)
+++ include/profile/vector	(working copy)
@@ -529,7 +529,7 @@ 
     : public __hash_base<size_t, __profile::vector<bool, _Alloc>>
     {
       size_t
-      operator()(const __profile::vector<bool, _Alloc>& __b) const
+      operator()(const __profile::vector<bool, _Alloc>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()
 	  (__b._M_base()); }
     };
Index: include/bits/shared_ptr.h
===================================================================
--- include/bits/shared_ptr.h	(revision 181470)
+++ include/bits/shared_ptr.h	(working copy)
@@ -619,7 +619,7 @@ 
     : public __hash_base<size_t, shared_ptr<_Tp>>
     {
       size_t
-      operator()(const shared_ptr<_Tp>& __s) const
+      operator()(const shared_ptr<_Tp>& __s) const noexcept
       { return std::hash<_Tp*>()(__s.get()); }
     };
 
Index: include/bits/functional_hash.h
===================================================================
--- include/bits/functional_hash.h	(revision 181470)
+++ include/bits/functional_hash.h	(working copy)
@@ -66,61 +66,64 @@ 
     struct hash<_Tp*> : public __hash_base<size_t, _Tp*>
     {
       size_t
-      operator()(_Tp* __p) const
+      operator()(_Tp* __p) const noexcept
       { return reinterpret_cast<size_t>(__p); }
     };
 
   // Explicit specializations for integer types.
 #define _Cxx_hashtable_define_trivial_hash(_Tp) 	\
   template<>						\
-    inline size_t					\
-    hash<_Tp>::operator()(_Tp __val) const		\
-    { return static_cast<size_t>(__val); }
+    struct hash<_Tp> : public __hash_base<size_t, _Tp>  \
+    {                                                   \
+      size_t                                            \
+      operator()(_Tp __val) const noexcept              \
+      { return static_cast<size_t>(__val); }            \
+    };
 
   /// Explicit specialization for bool.
-  _Cxx_hashtable_define_trivial_hash(bool);
+  _Cxx_hashtable_define_trivial_hash(bool)
 
   /// Explicit specialization for char.
-  _Cxx_hashtable_define_trivial_hash(char);
+  _Cxx_hashtable_define_trivial_hash(char)
 
   /// Explicit specialization for signed char.
-  _Cxx_hashtable_define_trivial_hash(signed char);
+  _Cxx_hashtable_define_trivial_hash(signed char)
 
   /// Explicit specialization for unsigned char.
-  _Cxx_hashtable_define_trivial_hash(unsigned char);
+  _Cxx_hashtable_define_trivial_hash(unsigned char)
 
   /// Explicit specialization for wchar_t.
-  _Cxx_hashtable_define_trivial_hash(wchar_t);
+  _Cxx_hashtable_define_trivial_hash(wchar_t)
 
   /// Explicit specialization for char16_t.
-  _Cxx_hashtable_define_trivial_hash(char16_t);
+  _Cxx_hashtable_define_trivial_hash(char16_t)
 
   /// Explicit specialization for char32_t.
-  _Cxx_hashtable_define_trivial_hash(char32_t);
+  _Cxx_hashtable_define_trivial_hash(char32_t)
 
   /// Explicit specialization for short.
-  _Cxx_hashtable_define_trivial_hash(short);
+  _Cxx_hashtable_define_trivial_hash(short)
 
   /// Explicit specialization for int.
-  _Cxx_hashtable_define_trivial_hash(int);
+  _Cxx_hashtable_define_trivial_hash(int)
 
   /// Explicit specialization for long.
-  _Cxx_hashtable_define_trivial_hash(long);
+  _Cxx_hashtable_define_trivial_hash(long)
 
   /// Explicit specialization for long long.
-  _Cxx_hashtable_define_trivial_hash(long long);
+  _Cxx_hashtable_define_trivial_hash(long long)
 
   /// Explicit specialization for unsigned short.
-  _Cxx_hashtable_define_trivial_hash(unsigned short);
+  _Cxx_hashtable_define_trivial_hash(unsigned short)
 
   /// Explicit specialization for unsigned int.
-  _Cxx_hashtable_define_trivial_hash(unsigned int);
+  _Cxx_hashtable_define_trivial_hash(unsigned int)
 
   /// Explicit specialization for unsigned long.
-  _Cxx_hashtable_define_trivial_hash(unsigned long);
+  _Cxx_hashtable_define_trivial_hash(unsigned long)
 
   /// Explicit specialization for unsigned long long.
-  _Cxx_hashtable_define_trivial_hash(unsigned long long);
+  _Cxx_hashtable_define_trivial_hash(unsigned long long)
 
 #undef _Cxx_hashtable_define_trivial_hash
 
@@ -162,26 +165,36 @@ 
 
   /// Specialization for float.
   template<>
-    inline size_t
-    hash<float>::operator()(float __val) const
+    struct hash<float> : public __hash_base<size_t, float>
     {
-      // 0 and -0 both hash to zero.
-      return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
-    }
+      size_t
+      operator()(float __val) const noexcept
+      {
+	// 0 and -0 both hash to zero.
+	return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
+      }
+    };
 
   /// Specialization for double.
   template<>
-    inline size_t
-    hash<double>::operator()(double __val) const
+    struct hash<double> : public __hash_base<size_t, double>
     {
-      // 0 and -0 both hash to zero.
-      return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
-    }
+      size_t
+      operator()(double __val) const noexcept
+      {
+	// 0 and -0 both hash to zero.
+	return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
+      }
+    };
 
   /// Specialization for long double.
   template<>
-    _GLIBCXX_PURE size_t
-    hash<long double>::operator()(long double __val) const;
+    struct hash<long double>
+    : public __hash_base<size_t, long double>
+    {
+      _GLIBCXX_PURE size_t
+      operator()(long double __val) const noexcept;
+    };
 
   // @} group hashes
 
Index: include/bits/unique_ptr.h
===================================================================
--- include/bits/unique_ptr.h	(revision 181470)
+++ include/bits/unique_ptr.h	(working copy)
@@ -545,7 +545,7 @@ 
     : public __hash_base<size_t, unique_ptr<_Tp, _Dp>>
     {
       size_t
-      operator()(const unique_ptr<_Tp, _Dp>& __u) const
+      operator()(const unique_ptr<_Tp, _Dp>& __u) const noexcept
       {
 	typedef unique_ptr<_Tp, _Dp> _UP;
 	return std::hash<typename _UP::pointer>()(__u.get());
Index: include/bits/basic_string.h
===================================================================
--- include/bits/basic_string.h	(revision 181470)
+++ include/bits/basic_string.h	(working copy)
@@ -3044,7 +3044,7 @@ 
     : public __hash_base<size_t, string>
     {
       size_t
-      operator()(const string& __s) const
+      operator()(const string& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(), __s.length()); }
     };
 
@@ -3055,7 +3055,7 @@ 
     : public __hash_base<size_t, wstring>
     {
       size_t
-      operator()(const wstring& __s) const
+      operator()(const wstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(wchar_t)); }
     };
@@ -3069,7 +3069,7 @@ 
     : public __hash_base<size_t, u16string>
     {
       size_t
-      operator()(const u16string& __s) const
+      operator()(const u16string& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char16_t)); }
     };
@@ -3080,7 +3080,7 @@ 
     : public __hash_base<size_t, u32string>
     {
       size_t
-      operator()(const u32string& __s) const
+      operator()(const u32string& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char32_t)); }
     };
Index: include/bits/vector.tcc
===================================================================
--- include/bits/vector.tcc	(revision 181470)
+++ include/bits/vector.tcc	(working copy)
@@ -818,7 +818,7 @@ 
   template<typename _Alloc>
     size_t
     hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
-    operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const
+    operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const noexcept
     {
       size_t __hash = 0;
       using _GLIBCXX_STD_C::_S_word_bit;
Index: include/bits/shared_ptr_base.h
===================================================================
--- include/bits/shared_ptr_base.h	(revision 181470)
+++ include/bits/shared_ptr_base.h	(working copy)
@@ -1450,7 +1450,7 @@ 
     : public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
     {
       size_t
-      operator()(const __shared_ptr<_Tp, _Lp>& __s) const
+      operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept
       { return std::hash<_Tp*>()(__s.get()); }
     };
 
Index: include/bits/stl_bvector.h
===================================================================
--- include/bits/stl_bvector.h	(revision 181470)
+++ include/bits/stl_bvector.h	(working copy)
@@ -1075,7 +1075,7 @@ 
     : public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>>
     {
       size_t
-      operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const;
+      operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>&) const noexcept;
     };
 
 _GLIBCXX_END_NAMESPACE_VERSION
Index: libsupc++/typeinfo
===================================================================
--- libsupc++/typeinfo	(revision 181470)
+++ libsupc++/typeinfo	(working copy)
@@ -140,7 +140,7 @@ 
     { return !operator==(__arg); }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
-    size_t hash_code() const throw()
+    size_t hash_code() const noexcept
     {
 #  if !__GXX_MERGED_TYPEINFO_NAMES
       return _Hash_bytes(name(), __builtin_strlen(name()),