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

            Bug ID: 64970
           Summary: Hard error instead of SFINAE for expression in nested
                    template alias
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com

The following code gives a hard error. I believe it should not.


template<typename T>
T && declval();

template<typename T>
struct void_ { using type = void; };

template<typename T>
using void_t = typename void_<T>::type;

template<class A, class B>
struct Outer
{
    template<class C, class D>
    using Inner = decltype(true ? declval<C>() : declval<D>());
};

template<class A, class B, typename Enable = void>
struct S
{};

template<class A, class B>
struct S<A, B, void_t<typename Outer<A, B>::template Inner<A, B>>>
{};

struct A{};
struct B{};
int main()
{
    S<A, B> s;
}


The error:

test.cpp: In substitution of ‘template<class A, class B> template<class C,
class D> using Inner = decltype ((true ?  declval<C>() : declval<D>())) [with C
= A; D = B; A = A; B = B]’:
test.cpp:32:13:   required from here
test.cpp:15:33: error: no match for ternary ‘operator?:’ (operand types are
‘bool’, ‘A’, and ‘B’)
     using Inner = decltype(true ? declval<C>() : declval<D>());
                                 ^

Reply via email to