https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65760

            Bug ID: 65760
           Summary: invalid use of incomplete type with
                    std::is_convertible<C, C>
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: etienne at atnnn dot com

The following code fails to compile with GCC 4.9.2 on Linux and OS X:

g++-4.9 -std=c++11 test.cc

I was not able to reduce the code any further:

* Commenting out 4, 5, 6, 7 or 11 causes the code to compile.

* Changing 'C c = C()' to 'C c' or 'C c; c = C()' also causes the code to
compile.

Code:

#include <functional>

struct C {
    C() = default;

    C(std::function<C(int)>);
    C(std::function<C(int, int)>);
    template <class T> C operator () (T&&);
    template <class T> C operator () (T&&, T&&);
};

int main() {
    C c = C();
}

Error output:

In file included from /opt/gcc-4.9.2/include/c++/4.9.2/bits/move.h:57:0,
                 from /opt/gcc-4.9.2/include/c++/4.9.2/bits/stl_pair.h:59,
                 from /opt/gcc-4.9.2/include/c++/4.9.2/utility:70,
                 from /opt/gcc-4.9.2/include/c++/4.9.2/tuple:38,
                 from /opt/gcc-4.9.2/include/c++/4.9.2/functional:55,
                 from test-gcc.cc:1:
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits: In instantiation of ‘struct
std::__and_<std::__not_<std::is_same<C, std::function<C(int, int)> > >,
std::__or_<std::is_void<C>, std::is_convertible<C, C> > >’:
/opt/gcc-4.9.2/include/c++/4.9.2/functional:2163:63:   required by substitution
of ‘template<class _Res, class ... _ArgTypes> template<class _Cond, class _Tp>
using _Requires = typename std::enable_if<_Cond:: value, _Tp>::type [with _Cond
= std::__and_<std::__not_<std::is_same<C, std::function<C(int, int)> > >,
std::__or_<std::is_void<C>, std::is_convertible<C, C> > >; _Tp = void; _Res =
C; _ArgTypes = {int, int}]’
/opt/gcc-4.9.2/include/c++/4.9.2/functional:2225:9:   required by substitution
of ‘template<class _Functor, class> std::function<_Res(_ArgTypes
...)>::function(_Functor) [with _Functor = C; <template-parameter-1-2> =
<missing>]’
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits:1401:39:   required by
substitution of ‘template<class _From1, class _To1, class> static
std::true_type std::__is_convertible_helper<_From, _To, false>::__test(int)
[with _From1 = C; _To1 = C; <template-parameter-1-3> = <missing>]’
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits:1410:30:   required from ‘struct
std::__is_convertible_helper<C, C, false>’
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits:1416:12:   required from ‘struct
std::is_convertible<C, C>’
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits:111:12:   required from ‘struct
std::__or_<std::is_void<C>, std::is_convertible<C, C> >’
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits:134:12:   required from ‘struct
std::__and_<std::__not_<std::is_same<C, std::function<C(int)> > >,
std::__or_<std::is_void<C>, std::is_convertible<C, C> > >’
/opt/gcc-4.9.2/include/c++/4.9.2/functional:2163:63:   required by substitution
of ‘template<class _Res, class ... _ArgTypes> template<class _Cond, class _Tp>
using _Requires = typename std::enable_if<_Cond:: value, _Tp>::type [with _Cond
= std::__and_<std::__not_<std::is_same<C, std::function<C(int)> > >,
std::__or_<std::is_void<C>, std::is_convertible<C, C> > >; _Tp = void; _Res =
C; _ArgTypes = {int}]’
/opt/gcc-4.9.2/include/c++/4.9.2/functional:2225:9:   required by substitution
of ‘template<class _Functor, class> std::function<_Res(_ArgTypes
...)>::function(_Functor) [with _Functor = C; <template-parameter-1-2> =
<missing>]’
test-gcc.cc:14:13:   required from here
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits:134:12: error: invalid use of
incomplete type ‘std::conditional<true, std::__or_<std::is_void<C>,
std::is_convertible<C, C> >, std::__not_<std::is_same<C, std::function<C(int,
int)> > > >::type {aka struct std::__or_<std::is_void<C>,
std::is_convertible<C, C> >}’
     struct __and_<_B1, _B2>
            ^
/opt/gcc-4.9.2/include/c++/4.9.2/type_traits:111:12: error: declaration of
‘std::conditional<true, std::__or_<std::is_void<C>, std::is_convertible<C, C>
>, std::__not_<std::is_same<C, std::function<C(int, int)> > > >::type {aka
struct std::__or_<std::is_void<C>, std::is_convertible<C, C> >}’
     struct __or_<_B1, _B2>

Reply via email to