Closed davidHysom closed 8 years ago
My guess would be that it's some kind of GCC / libstdc++ bug. Can you try with a newer version of GCC? (e.g. 5.x or 6.x)
It looks like http://stackoverflow.com/questions/26947704/implicit-conversion-failure-from-initializer-list/26949099#26949099, combined with g++ 4.9 and libstdc++ 4.9 supporting the -std=c++14 flag, but not properly supporting all of C++14 yet.
It should be easy to fix though: try changing tests/test_sequences_and_iterators.cpp
line 132 from the current single constructor:
StringMap(std::unordered_map<std::string, std::string> init = {})
: map(std::move(init)) {}
to the pair of constructors:
StringMap() = default;
StringMap(std::unordered_map<std::string, std::string> init)
: map(std::move(init)) {}
and report back if that works.
I downloaded/built g++ (GCC) 5.4.0 (had been using 4.9.2), and am now able to build/run the tests, without having to make changes to the pybind11 code.
thanks for your replies!
From: Jason Rhinelander [notifications@github.com] Sent: Saturday, November 12, 2016 4:56 PM To: pybind/pybind11 Cc: davidHysom; Author Subject: Re: [pybind/pybind11] make pytest fails (#495)
It looks like http://stackoverflow.com/questions/26947704/implicit-conversion-failure-from-initializer-list/26949099#26949099<redir.aspx?REF=NHSGKPMmv-SxH5NKV3qrLFDnptNnsAo8ZfavnPyd3a6hBj2UpgzUCAFodHRwOi8vc3RhY2tvdmVyZmxvdy5jb20vcXVlc3Rpb25zLzI2OTQ3NzA0L2ltcGxpY2l0LWNvbnZlcnNpb24tZmFpbHVyZS1mcm9tLWluaXRpYWxpemVyLWxpc3QvMjY5NDkwOTkjMjY5NDkwOTk.>, combined with libstdc++ 4.9 supporting the -std=c++14 flag, but not properly supporting all of C++14 yet.
It should be easy to fix though: try changing tests/test_sequences_and_iterators.cpp line 132 from the current single constructor:
StringMap(std::unordered_map<std::string, std::string> init = {})
: map(std::move(init)) {}
to the pair of constructors:
StringMap() = default;
StringMap(std::unordered_map<std::string, std::string> init)
: map(std::move(init)) {}
and report back if that works.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<redir.aspx?REF=4iu4LHMEJhqI0TqnfUHopcC1BQKatSJqTCvifNN3pb6hBj2UpgzUCAFodHRwczovL2dpdGh1Yi5jb20vcHliaW5kL3B5YmluZDExL2lzc3Vlcy80OTUjaXNzdWVjb21tZW50LTI2MDE1OTE4NQ..>, or mute the thread<redir.aspx?REF=GcMWyuYBr2mVtJAk2xHF6of88w31PC61Zv4LrrvyGrqhBj2UpgzUCAFodHRwczovL2dpdGh1Yi5jb20vbm90aWZpY2F0aW9ucy91bnN1YnNjcmliZS1hdXRoL0FJOERINXhmOV8tY3hBTUdqY2NyOFhrYk9qUFdsQTA1a3M1cTltQXNnYUpwWk00S3dqLXg.>.
It should work fine with 4.9.2 now as well (I could reproduce it; PR #496 fixed it and has been merged into master).
please let me know if there's a forum or mailing list where it would be better to submit.
I d/l pybind11 and successfully ran cmake (using gcc-4.9.2, Python 2.7.10) Unf, 'make pytest' fails; can you offer any advice? Thanks!
[ 3%] Building CXX object tests/CMakeFiles/pybind11_tests.dir/test_sequences_and_iterators.cpp.o /p/lscratche/hysom/pybind11/tests/test_sequences_and_iterators.cpp:132:68: error: converting to 'std::unordered_map<std::basic_string, std::basic_string >' from initializer list would use explicit constructor 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type, const hasher&, const key_equal&, const allocator_type&) [with _Key = std::basic_string; _Tp = std::basic_string; _Hash = std::hash<std::basic_string >; _Pred = std::equal_to<std::basic_string >; _Alloc = std::allocator<std::pair<const std::basic_string, std::basic_string > >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type = long unsigned int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hasher = std::hash<std::basic_string >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_equal = std::equal_to<std::basic_string >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::allocator_type = std::allocator<std::pair<const std::basic_string, std::basic_string > >]'
StringMap(std::unordered_map<std::string, std::string> init = {})
^
In file included from /p/lscratche/hysom/pybind11/tests/pybind11_tests.h:2:0,
from /p/lscratche/hysom/pybind11/tests/test_sequences_anditerators.cpp:11:
/p/lscratche/hysom/pybind11/include/pybind11/pybind11.h: In instantiation of 'pybind11::detail::init::execute(Class&, const Extra& ...)::<lambda(Base*, Args ...)> [with Class = pybind11::class ; Extra = {}; typename std::enable_if<(! Class:: hasalias), int>::type = 0; Args = {}; Base = StringMap]':
/p/lscratche/hysom/pybind11/include/pybind11/pybind11.h:1246:29: required from 'struct pybind11::detail::init::execute(Class&, const Extra& ...) [with Class = pybind11::class ; Extra = {}; typename std::enable_if<(! Class:: hasalias), int>::type = 0; Args = {}]::<lambda(using Base = using type = class StringMap*)>'
/p/lscratche/hysom/pybind11/include/pybind11/pybind11.h:1246:9: required from 'static void pybind11::detail::init::execute(Class&, const Extra& ...) [with Class = pybind11::class ; Extra = {}; typename std::enable_if<(! Class:: hasalias), int>::type = 0; Args = {}]'
/p/lscratche/hysom/pybind11/include/pybind11/pybind11.h:1005:9: required from 'pybind11::class <type, options>& pybind11::class<type, options>::def(const pybind11::detail::init<Args ...>&, const Extra& ...) [with Args = {}; Extra = {}; type = StringMap; options = {}]'
/p/lscratche/hysom/pybind11/tests/test_sequences_and_iterators.cpp:222:26: required from here
/p/lscratche/hysom/pybind11/include/pybind11/pybind11.h:1246:60: error: converting to 'std::unordered_map<std::basic_string, std::basic_string >' from initializer list would use explicit constructor 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type, const hasher&, const key_equal&, const allocator_type&) [with _Key = std::basic_string; _Tp = std::basic_string; _Hash = std::hash<std::basic_string >; _Pred = std::equal_to<std::basic_string >; _Alloc = std::allocator<std::pair<const std::basic_string, std::basic_string > >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type = long unsigned int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hasher = std::hash<std::basic_string >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_equal = std::equal_to<std::basic_string >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::allocator_type = std::allocator<std::pair<const std::basic_string, std::basicstring > >]'
cl.def("init", [](Base *self , Args... args) { new (self) Base(args...); }, extra...);
^
/p/lscratche/hysom/pybind11/include/pybind11/pybind11.h:976:13: error: 'pybind11::class<type, options>& pybind11::class<type, options>::def(const char*, Func&&, const Extra& ...) [with Func = pybind11::detail::init::execute(Class&, const Extra& ...) [with Class = pybind11::class ; Extra = {}; typename std::enable_if<(! Class:: hasalias), int>::type = 0; Args = {}]::<lambda(Base*)>; Extra = {}; type = StringMap; options = {}]', declared using local type 'pybind11::detail::init::execute(Class&, const Extra& ...) [with Class = pybind11::class_; Extra = {}; typename std::enable_if<(! Class:: hasalias), int>::type = 0; Args = {}]::<lambda(Base*)>', is used but never defined [-fpermissive]
class &def(const char *name_, Func&& f, const Extra&... extra) {
^
make[3]: *** [tests/CMakeFiles/pybind11_tests.dir/test_sequences_and_iterators.cpp.o] Error 1