[llvm-bugs] [Bug 30979] New: is_constructible_v<tuple<move_only>, const move_only&> explodes

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 10 12:41:40 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=30979

            Bug ID: 30979
           Summary: is_constructible_v<tuple<move_only>, const move_only&>
                    explodes
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rs2740 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

#include <tuple>

struct move_only
{
    move_only() = default;
    move_only(move_only&&) = default;
};

static_assert(!std::is_constructible_v<std::tuple<move_only>, const move_only
&>);

results in (http://melpon.org/wandbox/permlink/7eV9ndEz2fYroRgZ):

In file included from prog.cc:1:
/usr/local/libcxx-head/include/c++/v1/tuple:385:13: error: no matching
constructor for initialization of '__tuple_leaf<0UL, move_only>'
            __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
            ^                      ~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/libcxx-head/include/c++/v1/tuple:641:11: note: in instantiation of
function template specialization
'std::__1::__tuple_impl<std::__1::__tuple_indices<0>,
move_only>::__tuple_impl<0, move_only, const move_only &>' requested here
        : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
          ^
/usr/local/libcxx-head/include/c++/v1/type_traits:3016:38: note: in
instantiation of function template specialization
'std::__1::tuple<move_only>::tuple<true, false>' requested here
    : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
                                     ^
/usr/local/libcxx-head/include/c++/v1/type_traits:3200:7: note: in
instantiation of template class
'std::__1::is_constructible<std::__1::tuple<move_only>, const move_only &>'
requested here
    = is_constructible<_Tp, _Args...>::value;
      ^
prog.cc:9:21: note: in instantiation of variable template specialization
'std::__1::is_constructible_v<std::__1::tuple<move_only>, const move_only &>'
requested here
static_assert(!std::is_constructible_v<std::tuple<move_only>, const move_only
&>);
                    ^
/usr/local/libcxx-head/include/c++/v1/tuple:325:5: note: candidate constructor
not viable: no known conversion from 'const move_only' to 'const
std::__1::__tuple_leaf<0, move_only, true>' for 1st argument
    __tuple_leaf(__tuple_leaf const &) = default;
    ^
/usr/local/libcxx-head/include/c++/v1/tuple:326:5: note: candidate constructor
not viable: no known conversion from 'const move_only' to
'std::__1::__tuple_leaf<0, move_only, true>' for 1st argument
    __tuple_leaf(__tuple_leaf &&) = default;
    ^
/usr/local/libcxx-head/include/c++/v1/tuple:300:19: note: candidate template
ignored: disabled by 'enable_if' [with _Tp = const move_only &]
                  __lazy_and<
                  ^
/usr/local/libcxx-head/include/c++/v1/tuple:286:9: note: candidate constructor
template not viable: requires 2 arguments, but 1 was provided
        __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
        ^
/usr/local/libcxx-head/include/c++/v1/tuple:290:9: note: candidate constructor
template not viable: requires 2 arguments, but 1 was provided
        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
        ^
/usr/local/libcxx-head/include/c++/v1/tuple:295:9: note: candidate constructor
template not viable: requires 2 arguments, but 1 was provided
        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
        ^
/usr/local/libcxx-head/include/c++/v1/tuple:312:18: note: candidate constructor
template not viable: requires 3 arguments, but 1 was provided
        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&&
__t)
                 ^
/usr/local/libcxx-head/include/c++/v1/tuple:317:18: note: candidate constructor
template not viable: requires 3 arguments, but 1 was provided
        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a,
_Tp&& __t)
                 ^
/usr/local/libcxx-head/include/c++/v1/tuple:322:18: note: candidate constructor
template not viable: requires 3 arguments, but 1 was provided
        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a,
_Tp&& __t)
                 ^
/usr/local/libcxx-head/include/c++/v1/tuple:281:49: note: candidate constructor
not viable: requires 0 arguments, but 1 was provided
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
                                                ^
prog.cc:9:1: error: static_assert failed
static_assert(!std::is_constructible_v<std::tuple<move_only>, const move_only
&>);
^            
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

I might be reading the code wrong, but it seems to me that for the constructors
taking const _Tp&..., the _CheckArgsConstructor<_Dummy>::template
__enable_implicit<_Tp...>() in the SFINAE condition should use
__enable_implicit<const _Tp&...> instead (and likewise for the explicit
variant).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161110/7665620d/attachment.html>


More information about the llvm-bugs mailing list