-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.5.0
-
Component/s: Internal Client
-
Environment:clang++ --version
Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
Mac os X 10.8.3
Boost 1.53 compiled with clang/clang++
-
Fully Compatible
-
OS X
-
I am using the mongodb from the git main trunk for some compatibility and integration tests. I use the clang with -std=c++11 flags for compiling my source.
Yesterday I updated my local repository (It was not updated for 3 weeks).
Since I did it, I am having troubles when I try to compile my code.
~/development/mongo/src/mongo/client]$ clang++ -std=c++11 -I/opt/mongo/include -I/opt/boost/include -L/opt/boost-clang/lib/ -L/opt/mongo/lib/ -lmongoclient -lboost_thread -lboost_filesystem -lboost_program_options -lboost_system simple_client_demo.cpp -o test
lboost_filesystem -lboost_program_options -lboost_system simple_client_demo.cpp -o test
In file included from simple_client_demo.cpp:32:
In file included from ./dbclient.h:32:
In file included from /opt/mongo/include/mongo/client/connpool.h:23:
In file included from /opt/mongo/include/mongo/client/dbclientinterface.h:27:
In file included from /opt/mongo/include/mongo/util/net/message.h:21:
In file included from /opt/mongo/include/mongo/util/net/hostandport.h:21:
In file included from /opt/mongo/include/mongo/db/cmdline.h:23:
/opt/mongo/include/mongo/platform/process_id.h:107:19: error: no template named 'hash'; did you mean 'boost::hash'?
template<> struct hash< ::mongo::ProcessId > {
^~~~
boost::hash
/opt/boost/include/boost/functional/hash/hash_fwd.hpp:23:31: note: 'boost::hash' declared here
template <class T> struct hash;
^
In file included from simple_client_demo.cpp:32:
In file included from ./dbclient.h:32:
In file included from /opt/mongo/include/mongo/client/connpool.h:23:
In file included from /opt/mongo/include/mongo/client/dbclientinterface.h:27:
In file included from /opt/mongo/include/mongo/util/net/message.h:21:
In file included from /opt/mongo/include/mongo/util/net/hostandport.h:21:
In file included from /opt/mongo/include/mongo/db/cmdline.h:23:
/opt/mongo/include/mongo/platform/process_id.h:107:19: error: class template specialization of 'hash' must originally be declared in namespace 'boost'
template<> struct hash< ::mongo::ProcessId > {
^
/opt/boost/include/boost/functional/hash/hash_fwd.hpp:23:31: note: explicitly specialized declaration is here
template <class T> struct hash;
^
In file included from simple_client_demo.cpp:32:
In file included from ./dbclient.h:32:
In file included from /opt/mongo/include/mongo/client/connpool.h:23:
In file included from /opt/mongo/include/mongo/client/dbclientinterface.h:27:
In file included from /opt/mongo/include/mongo/util/net/message.h:21:
In file included from /opt/mongo/include/mongo/util/net/hostandport.h:21:
In file included from /opt/mongo/include/mongo/db/cmdline.h:23:
/opt/mongo/include/mongo/platform/process_id.h:109:16: error: implicit instantiation of undefined template 'boost::hash<unsigned int>'
return hash< ::mongo::uint32_t >()(pid.asUInt32());
^
/opt/boost/include/boost/functional/hash/hash_fwd.hpp:23:31: note: template is declared here
template <class T> struct hash;
^
3 errors generated.
I realized that the file , platform/process_id.h that gives me the erros ir quite new (just 16 dayss old):
https://github.com/mongodb/mongo/commits/master/src/mongo/platform/process_id.h
And if I delete the lines
106 MONGO_HASH_NAMESPACE_START
107 template<> struct hash< ::mongo::ProcessId > {
108 size_t operator()(const ::mongo::ProcessId pid) const
111 };
112 MONGO_HASH_NAMESPACE_END
The code compiles and it is executed without any issue. (My actual work arround)
By the way, if I compile without the -std=c++11 flag, it is compiled without any error.
I also tried to compiled mongodb with clang:
scons --full install --64=FORCE64 -j 16 --prefix /opt/mongo --use-system-boost --extrapath=/opt/boost/ --cc=clang --cxx=clang++ --c++11 --allocator=system
but I got the same erros:
In file included from src/mongo/platform/process_id.cpp:18:
src/mongo/platform/process_id.h:107:19: error: explicit specialization of non-template struct 'hash'
template<> struct hash< ::mongo::ProcessId > {
^ ~~~~~~~~~~~~~~~~~~~~~~
src/mongo/platform/process_id.h:109:20: error: expected '(' for function-style cast or type construction
return hash< ::mongo::uint32_t >()(pid.asUInt32());
~~~~^
src/mongo/platform/process_id.h:109:40: error: expected '(' for function-style cast or type construction
return hash< ::mongo::uint32_t >()(pid.asUInt32());
~~~~~~~~~~~~~~~~~ ^
src/mongo/platform/process_id.h:109:42: error: expected expression