Skip to content

Build failure with clang 3.8.0 #964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rleigh-codelibre opened this issue Jul 27, 2017 · 4 comments
Closed

Build failure with clang 3.8.0 #964

rleigh-codelibre opened this issue Jul 27, 2017 · 4 comments

Comments

@rleigh-codelibre
Copy link

rleigh-codelibre commented Jul 27, 2017

Issue description

Build failure with error on clang 3.8.0 (FreeBSD 11.0p11 amd64, Python 2.7.13)

Reproducible example code

See full build log here: https://gist.github.com/rleigh-codelibre/6d6a8cb7888a0cf9c1db365990bdb646

The specific error is when compiling tests/test_stl_binders.cpp and is copied here. It looks like this is due to the deleted copy constructor:

    E_nc(const E_nc &) = delete;
Building CXX object tests/CMakeFiles/pybind11_tests.dir/test_stl_binders.cpp.o
cd /tmp/pb/tests && /usr/bin/CC  -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS -I/home/rleigh/code/pybind11/include -I/usr/local/include/python2.7 -isystem /usr/local/include/eigen3 -Os -DNDEBUG -fPIC   -std=c++14 -fvisibility=hidden -Wall -Wextra -Wconversion -Wcast-qual -o CMakeFiles/pybind11_tests.dir/test_stl_binders.cpp.o -c /home/rleigh/code/pybind11/tests/test_stl_binders.cpp
In file included from /home/rleigh/code/pybind11/tests/test_stl_binders.cpp:10:
In file included from /home/rleigh/code/pybind11/tests/pybind11_tests.h:2:
In file included from /home/rleigh/code/pybind11/include/pybind11/pybind11.h:43:
In file included from /home/rleigh/code/pybind11/include/pybind11/attr.h:13:
In file included from /home/rleigh/code/pybind11/include/pybind11/cast.h:13:
In file included from /home/rleigh/code/pybind11/include/pybind11/pytypes.h:12:
In file included from /home/rleigh/code/pybind11/include/pybind11/common.h:128:
In file included from /usr/include/c++/v1/forward_list:172:
In file included from /usr/include/c++/v1/memory:604:
/usr/include/c++/v1/utility:322:11: error: call to deleted constructor of 'E_nc'
          second(__p.second)
          ^      ~~~~~~~~~~
/usr/include/c++/v1/map:634:11: note: in instantiation of member function
      'std::__1::pair<const int, E_nc>::pair' requested here
        : __cc(std::forward<_Args>(__args)...) {}
          ^
/usr/include/c++/v1/memory:1740:31: note: in instantiation of function template
      specialization 'std::__1::__value_type<int, E_nc>::__value_type<const
      std::__1::pair<const int, E_nc> &>' requested here
            ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
                              ^
/usr/include/c++/v1/memory:1656:18: note: in instantiation of function template
      specialization
      'std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<int,
      E_nc>, void *> >::construct<std::__1::__value_type<int, E_nc>, const
      std::__1::pair<const int, E_nc> &>' requested here
            {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
                 ^
/usr/include/c++/v1/memory:1502:14: note: in instantiation of function template
      specialization
      'std::__1::allocator_traits<std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<int,
      E_nc>, void *> > >::__construct<std::__1::__value_type<int, E_nc>, const
      std::__1::pair<const int, E_nc> &>' requested here
            {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
             ^
/usr/include/c++/v1/__tree:1671:20: note: in instantiation of function template
      specialization
      'std::__1::allocator_traits<std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<int,
      E_nc>, void *> > >::construct<std::__1::__value_type<int, E_nc>, const
      std::__1::pair<const int, E_nc> &>' requested here
    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VST...
                   ^
/usr/include/c++/v1/__tree:1778:25: note: (skipping 5 contexts in backtrace; use
      -ftemplate-backtrace-limit=0 to see all)
    __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v));
                        ^
/home/rleigh/code/pybind11/include/pybind11/cast.h:819:13: note: in
      instantiation of function template specialization
      'pybind11::detail::type_caster_base<std::__1::map<int, E_nc,
      std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, E_nc> >
      > >::make_copy_constructor<std::__1::map<int, E_nc, std::__1::less<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > >, void>' requested
      here
            make_copy_constructor(src), make_move_constructor(src));
            ^
/home/rleigh/code/pybind11/include/pybind11/pybind11.h:157:39: note: in
      instantiation of member function
      'pybind11::detail::type_caster_base<std::__1::map<int, E_nc,
      std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, E_nc> >
      > >::cast' requested here
            handle result = cast_out::cast(
                                      ^
/home/rleigh/code/pybind11/include/pybind11/pybind11.h:57:9: note: in
      instantiation of function template specialization
      'pybind11::cpp_function::initialize<std::__1::map<int, E_nc,
      std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, E_nc> >
      > *(*&)(int), std::__1::map<int, E_nc, std::__1::less<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > > *, int,
      pybind11::name, pybind11::scope, pybind11::sibling,
      pybind11::return_value_policy>' requested here
        initialize(f, f, extra...);
        ^
/home/rleigh/code/pybind11/include/pybind11/pybind11.h:755:22: note: in
      instantiation of function template specialization
      'pybind11::cpp_function::cpp_function<std::__1::map<int, E_nc,
      std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, E_nc> >
      > *, int, pybind11::name, pybind11::scope, pybind11::sibling,
      pybind11::return_value_policy>' requested here
        cpp_function func(std::forward<Func>(f), name(name_), scope(*this),
                     ^
/home/rleigh/code/pybind11/tests/test_stl_binders.cpp:119:7: note: in
      instantiation of function template specialization
      'pybind11::module::def<std::__1::map<int, E_nc, std::__1::less<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > > *(*)(int),
      pybind11::return_value_policy>' requested here
    m.def("get_mnc", &times_ten<std::map<int, E_nc>>, py::return_value_p...
      ^
/home/rleigh/code/pybind11/tests/test_stl_binders.cpp:35:5: note: 'E_nc' has
      been explicitly marked deleted here
    E_nc(const E_nc &) = delete;
    ^
In file included from /home/rleigh/code/pybind11/tests/test_stl_binders.cpp:10:
In file included from /home/rleigh/code/pybind11/tests/pybind11_tests.h:2:
In file included from /home/rleigh/code/pybind11/include/pybind11/pybind11.h:43:
In file included from /home/rleigh/code/pybind11/include/pybind11/attr.h:13:
In file included from /home/rleigh/code/pybind11/include/pybind11/cast.h:13:
In file included from /home/rleigh/code/pybind11/include/pybind11/pytypes.h:12:
In file included from /home/rleigh/code/pybind11/include/pybind11/common.h:133:
/usr/include/c++/v1/unordered_map:605:11: error: no matching constructor for
      initialization of 'value_type' (aka 'pair<const int, E_nc>')
        : __cc(std::forward<_Args>(__args)...) {}
          ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/memory:1740:31: note: in instantiation of function template
      specialization 'std::__1::__hash_value_type<int,
      E_nc>::__hash_value_type<const std::__1::pair<const int, E_nc> &>'
      requested here
            ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
                              ^
/usr/include/c++/v1/memory:1656:18: note: in instantiation of function template
      specialization
      'std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int,
      E_nc>, void *> >::construct<std::__1::__hash_value_type<int, E_nc>, const
      std::__1::pair<const int, E_nc> &>' requested here
            {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
                 ^
/usr/include/c++/v1/memory:1502:14: note: in instantiation of function template
      specialization
      'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int,
      E_nc>, void *> > >::__construct<std::__1::__hash_value_type<int, E_nc>,
      const std::__1::pair<const int, E_nc> &>' requested here
            {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
             ^
/usr/include/c++/v1/__hash_table:2044:20: note: in instantiation of function
      template specialization
      'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int,
      E_nc>, void *> > >::construct<std::__1::__hash_value_type<int, E_nc>,
      const std::__1::pair<const int, E_nc> &>' requested here
    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VST...
                   ^
/usr/include/c++/v1/__hash_table:1828:25: note: in instantiation of function
      template specialization
      'std::__1::__hash_table<std::__1::__hash_value_type<int, E_nc>,
      std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int,
      E_nc>, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int,
      std::__1::__hash_value_type<int, E_nc>, std::__1::equal_to<int>, true>,
      std::__1::allocator<std::__1::__hash_value_type<int, E_nc> >
      >::__construct_node<const std::__1::pair<const int, E_nc> &>' requested
      here
    __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x));
                        ^
/usr/include/c++/v1/unordered_map:1513:18: note: (skipping 3 contexts in
      backtrace; use -ftemplate-backtrace-limit=0 to see all)
        __table_.__insert_unique(*__first);
                 ^
/home/rleigh/code/pybind11/include/pybind11/cast.h:819:13: note: in
      instantiation of function template specialization
      'pybind11::detail::type_caster_base<std::__1::unordered_map<int, E_nc,
      std::__1::hash<int>, std::__1::equal_to<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > >
      >::make_copy_constructor<std::__1::unordered_map<int, E_nc,
      std::__1::hash<int>, std::__1::equal_to<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > >, void>' requested
      here
            make_copy_constructor(src), make_move_constructor(src));
            ^
/home/rleigh/code/pybind11/include/pybind11/pybind11.h:157:39: note: in
      instantiation of member function
      'pybind11::detail::type_caster_base<std::__1::unordered_map<int, E_nc,
      std::__1::hash<int>, std::__1::equal_to<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > > >::cast' requested
      here
            handle result = cast_out::cast(
                                      ^
/home/rleigh/code/pybind11/include/pybind11/pybind11.h:57:9: note: in
      instantiation of function template specialization
      'pybind11::cpp_function::initialize<std::__1::unordered_map<int, E_nc,
      std::__1::hash<int>, std::__1::equal_to<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > > *(*&)(int),
      std::__1::unordered_map<int, E_nc, std::__1::hash<int>,
      std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int,
      E_nc> > > *, int, pybind11::name, pybind11::scope, pybind11::sibling,
      pybind11::return_value_policy>' requested here
        initialize(f, f, extra...);
        ^
/home/rleigh/code/pybind11/include/pybind11/pybind11.h:755:22: note: in
      instantiation of function template specialization
      'pybind11::cpp_function::cpp_function<std::__1::unordered_map<int, E_nc,
      std::__1::hash<int>, std::__1::equal_to<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > > *, int,
      pybind11::name, pybind11::scope, pybind11::sibling,
      pybind11::return_value_policy>' requested here
        cpp_function func(std::forward<Func>(f), name(name_), scope(*this),
                     ^
/home/rleigh/code/pybind11/tests/test_stl_binders.cpp:122:7: note: in
      instantiation of function template specialization
      'pybind11::module::def<std::__1::unordered_map<int, E_nc,
      std::__1::hash<int>, std::__1::equal_to<int>,
      std::__1::allocator<std::__1::pair<const int, E_nc> > > *(*)(int),
      pybind11::return_value_policy>' requested here
    m.def("get_umnc", &times_ten<std::unordered_map<int, E_nc>>, py::ret...
      ^
/usr/include/c++/v1/utility:358:5: note: candidate constructor not viable: 1st
      argument ('const std::__1::pair<const int, E_nc>') would lose const
      qualifier
    pair(pair&& __p) = default;
    ^
/usr/include/c++/v1/utility:307:38: note: candidate template ignored: disabled
      by 'enable_if' [with _U1 = const int, _U2 = E_nc]
                 ,typename enable_if<is_convertible<const _U1&, _T1>::value &&
                                     ^
/usr/include/c++/v1/utility:350:9: note: candidate template ignored: deduced
      type 'pair<const int, E_nc> &&' of 1st parameter does not match adjusted
      type 'const std::__1::pair<const int, E_nc>' of argument [with _U1 = const
      int, _U2 = E_nc]
        pair(pair<_U1, _U2>&& __p,
        ^
/usr/include/c++/v1/utility:382:41: note: candidate template ignored: disabled
      by 'enable_if' [with _Tuple = const std::__1::pair<const int, E_nc> &]
             class = typename enable_if<__tuple_convertible<_Tuple, pair...
                                        ^
/usr/include/c++/v1/utility:297:49: note: candidate constructor template not
      viable: requires 0 arguments, but 1 was provided
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
                                                ^
/usr/include/c++/v1/utility:343:9: note: candidate constructor template not
      viable: requires 2 arguments, but 1 was provided
        pair(_U1&& __u1, _U2&& __u2)
        ^
/usr/include/c++/v1/utility:395:9: note: candidate constructor template not
      viable: requires 3 arguments, but 1 was provided
        pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
        ^
/usr/include/c++/v1/utility:433:9: note: candidate constructor template not
      viable: requires 5 arguments, but 1 was provided
        pair(piecewise_construct_t,
        ^
/usr/include/c++/v1/utility:300:5: note: candidate constructor not viable:
      requires 2 arguments, but 1 was provided
    pair(const _T1& __x, const _T2& __y)
    ^
2 errors generated.

I've tested with clang 4.0.0 (upgraded setup, with FreeBSD 11.1, amd64, Python 2.7.13). I can't reproduce the issue with this version of clang/llvm.

@rleigh-codelibre
Copy link
Author

Applying this patch

index 22ba16e..4886190 100644
--- a/tests/test_stl_binders.cpp
+++ b/tests/test_stl_binders.cpp
@@ -32,9 +32,10 @@ std::ostream & operator<<(std::ostream &s, El const&v) {
 class E_nc {
 public:
     explicit E_nc(int i) : value{i} {}
-    E_nc(const E_nc &) = delete;
-    E_nc &operator=(const E_nc &) = delete;
+    E_nc(const E_nc &) = default;
+    E_nc &operator=(const E_nc &) = default;
     E_nc(E_nc &&) = default;
+    ~E_nc() = default;
     E_nc &operator=(E_nc &&) = default;
 
     int value;

Fixes the above problem, but leads to another failure by causing std_bind Vector to call reserve() on std::deque, so it's not the solution it seems.

cd /tmp/pb/tests && /usr/bin/CC  -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS -I/home/rleigh/code/pybind11/include -I/usr/local/include/python2.7 -isystem /usr/local/include/eigen3 -Os -DNDEBUG -fPIC   -std=c++14 -fvisibility=hidden -Wall -Wextra -Wconversion -Wcast-qual -o CMakeFiles/pybind11_tests.dir/test_stl_binders.cpp.o -c /home/rleigh/code/pybind11/tests/test_stl_binders.cpp
In file included from /home/rleigh/code/pybind11/tests/test_stl_binders.cpp:12:
/home/rleigh/code/pybind11/include/pybind11/stl_bind.h:129:15: error: no member
      named 'reserve' in 'std::__1::deque<E_nc, std::__1::allocator<E_nc> >'
            v.reserve(len(it));
            ~ ^
/home/rleigh/code/pybind11/include/pybind11/stl_bind.h:399:13: note: in
      instantiation of function template specialization
      'pybind11::detail::vector_modifiers<std::__1::deque<E_nc,
      std::__1::allocator<E_nc> >, pybind11::class_<std::__1::deque<E_nc,
      std::__1::allocator<E_nc> >, std::__1::unique_ptr<std::__1::deque<E_nc,
      std::__1::allocator<E_nc> >,
      std::__1::default_delete<std::__1::deque<E_nc, std::__1::allocator<E_nc> >
      > > > >' requested here
    detail::vector_modifiers<Vector, Class_>(cl);
            ^
/home/rleigh/code/pybind11/tests/test_stl_binders.cpp:116:9: note: in
      instantiation of function template specialization
      'pybind11::bind_vector<std::__1::deque<E_nc, std::__1::allocator<E_nc> >,
      std::__1::unique_ptr<std::__1::deque<E_nc, std::__1::allocator<E_nc> >,
      std::__1::default_delete<std::__1::deque<E_nc, std::__1::allocator<E_nc> >
      > >>' requested here
    py::bind_vector<std::deque<E_nc>>(m, "DequeENC");
        ^
In file included from /home/rleigh/code/pybind11/tests/test_stl_binders.cpp:12:
/home/rleigh/code/pybind11/include/pybind11/stl_bind.h:196:18: error: no member
      named 'reserve' in 'std::__1::deque<E_nc, std::__1::allocator<E_nc> >'
            seq->reserve((size_t) slicelength);
            ~~~  ^

@jagerman
Copy link
Member

Applying this patch ...

The nc in E_nc stands for non-copyable; making it copyable defeats the purpose of the test.

Can you test whether 24dec80 works (and whether the subsequent commit, ce7024f, fails)?

@rleigh-codelibre
Copy link
Author

rleigh-codelibre commented Jul 27, 2017

@jagerman Both these commits fail in the same way, plus v2.0.0.

Bisection showed it started failing in 617fbcf (Fix stl_bind to support movable, non-copyable value types (#490)).

@jagerman
Copy link
Member

It looks like FreeBSD patched libc++ and broke this, here:

https://svnweb.freebsd.org/base?view=revision&revision=261801

With that change, this code:

#include <type_traits>
#include <iostream>
#include <utility>

struct A {
        A(const A &) = delete;
};

int main() {
        std::cerr << std::is_copy_constructible<std::pair<std::string, A>>::value << "\n";
        std::cerr << std::is_copy_constructible<std::pair<A, std::string>>::value << "\n";
        std::cerr << std::is_copy_constructible<std::pair<std::string, std::string>>::value << "\n";
        std::cerr << std::is_copy_constructible<std::pair<A, A>>::value << "\n";
}

produces:

1
1
1
1

while the other major stls (and libc++ itself, without FreeBSDs bad patch) produce:

0
0
1
0

FreeBSD seems to be violating the spirit (if not the letter) of the standard (at least until C++17, which does requires such a std::pair not be copy constructible).

#965 fixes this (at least in my FreeBSD VM).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants