This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
pedantic error: incongruent exception specifications in TR1 <functional>
- From: John Freeman <jfreeman08 at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Thu, 06 Aug 2009 12:06:44 -0500
- Subject: pedantic error: incongruent exception specifications in TR1 <functional>
$ ./g++ --version
g++ (GCC) 4.5.0 20090803 (experimental)
$ cat test.cpp
#include <functional>
Compiling the attached test with options
g++ -std=c++0x -pedantic -c test.cpp
gives the error
In file included from
/.../install/bin/../lib/gcc/i386-apple-darwin9.6.0/4.5.0/../../../../include/c++/4.5.0/functional:61:0,
from test.cpp:1:
/.../install/bin/../lib/gcc/i386-apple-darwin9.6.0/4.5.0/../../../../include/c++/4.5.0/bits/functional_hash.h:64:59:
error: declaration of âsize_t std::hash<_Tp>::operator()(_Tp) const
throw () [with _Tp = std::error_code, size_t = long unsigned int]â
throws different exceptions
/.../install/bin/../lib/gcc/i386-apple-darwin9.6.0/4.5.0/../../../../include/c++/4.5.0/tr1_impl/functional_hash.h:41:7:
error: from previous declaration âsize_t std::hash<_Tp>::operator()(_Tp)
const [with _Tp = std::error_code, size_t = long unsigned int]â
The fix is either to remove the empty exception specification from
bits/functional_hash.h or to add it in all the right places to
tr1_impl/functional_hash.h. Attached patch does the latter.
Reading through all the steps for submitting patches at
http://gcc.gnu.org/contribute.html#patches makes me feel like I'm
filling out my taxes. Please someone just take the patch.
Thanks,
John
#include <functional>
Index: libstdc++-v3/include/tr1_impl/functional_hash.h
===================================================================
--- libstdc++-v3/include/tr1_impl/functional_hash.h (revision 150525)
+++ libstdc++-v3/include/tr1_impl/functional_hash.h (working copy)
@@ -38,7 +38,7 @@
struct hash : public std::unary_function<_Tp, size_t>
{
size_t
- operator()(_Tp __val) const;
+ operator()(_Tp __val) const throw ();
};
/// Partial specializations for pointer types.
@@ -46,7 +46,7 @@
struct hash<_Tp*> : public std::unary_function<_Tp*, size_t>
{
size_t
- operator()(_Tp* __p) const
+ operator()(_Tp* __p) const throw ()
{ return reinterpret_cast<size_t>(__p); }
};
@@ -54,7 +54,7 @@
#define _TR1_hashtable_define_trivial_hash(_Tp) \
template<> \
inline size_t \
- hash<_Tp>::operator()(_Tp __val) const \
+ hash<_Tp>::operator()(_Tp __val) const throw () \
{ return static_cast<size_t>(__val); }
_TR1_hashtable_define_trivial_hash(bool);
@@ -130,7 +130,7 @@
/// Explicit specializations for float.
template<>
inline size_t
- hash<float>::operator()(float __val) const
+ hash<float>::operator()(float __val) const throw ()
{
size_t __result = 0;
@@ -144,7 +144,7 @@
/// Explicit specializations for double.
template<>
inline size_t
- hash<double>::operator()(double __val) const
+ hash<double>::operator()(double __val) const throw ()
{
size_t __result = 0;
@@ -158,25 +158,25 @@
/// Explicit specializations for long double.
template<>
_GLIBCXX_PURE size_t
- hash<long double>::operator()(long double __val) const;
+ hash<long double>::operator()(long double __val) const throw ();
/// Explicit specialization of member operator for non-builtin types.
template<>
_GLIBCXX_PURE size_t
- hash<string>::operator()(string) const;
+ hash<string>::operator()(string) const throw ();
template<>
_GLIBCXX_PURE size_t
- hash<const string&>::operator()(const string&) const;
+ hash<const string&>::operator()(const string&) const throw ();
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
_GLIBCXX_PURE size_t
- hash<wstring>::operator()(wstring) const;
+ hash<wstring>::operator()(wstring) const throw ();
template<>
_GLIBCXX_PURE size_t
- hash<const wstring&>::operator()(const wstring&) const;
+ hash<const wstring&>::operator()(const wstring&) const throw ();
#endif
_GLIBCXX_END_NAMESPACE_TR1