[LLVMbugs] [Bug 22079] New: inheriting constructor leads to erroneous SFINAE error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 1 08:49:44 PST 2015


            Bug ID: 22079
           Summary: inheriting constructor leads to erroneous SFINAE error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eniebler at boost.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code fails to compile. I believe it should, and does with gcc.

#include <type_traits>
#include <utility>

template<typename T>
using decay_t = typename std::decay<T>::type;

template <class _T1, class _T2>
struct pair
    typedef _T1 first_type;
    typedef _T2 second_type;

    _T1 first;
    _T2 second;

    // pair(const pair&) = default;
    // pair(pair&&) = default;

    constexpr pair() : first(), second() {}

    pair(const _T1& __x, const _T2& __y)
        : first(__x), second(__y) {}

    template<class _U1, class _U2>
        pair(const pair<_U1, _U2>& __p
                 ,typename std::enable_if<std::is_convertible<const _U1&,
_T1>::value &&
                                    std::is_convertible<const _U2&,
_T2>::value>::type* = 0
            : first(__p.first), second(__p.second) {}


template<typename F, typename S>
struct pair_ref
  : ::pair<F, S>
    using ::pair<F, S>::pair;
    pair_ref(::pair<decay_t<F>, decay_t<S>> & val)
       : ::pair<F, S>{val.first, val.second}
    using ::pair<F, S>::operator=;

int main()
::pair_ref<int&,int&>>::value, "");

The error I see is:

error: no type named 'type' in
      'std::enable_if<false, void>'; 'enable_if' cannot be used to disable this
                 ,typename std::enable_if<std::is_convertible<const _U1&,
_T1>::value &&
note: in instantiation of member function
      'pair<int &, int &>::pair' requested here
    using ::pair<F, S>::pair;

There is no reason I can see why SFINAE should not be able to disable the
inherited constructor. If the constructor in question is copied into the
derived class (and renamed appropriately), the code compiles just fine.

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/20150101/9dfb22e2/attachment.html>

More information about the llvm-bugs mailing list