pedantic error: incongruent exception specifications in TR1 <functional>

John Freeman jfreeman08@gmail.com
Thu Aug 6 17:07:00 GMT 2009


$ ./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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cpp
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20090806/ceb51d18/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: missing_exception_specs.patch
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20090806/ceb51d18/attachment-0001.ksh>


More information about the Libstdc++ mailing list