http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48285

           Summary: [C++0x] ICE in tsubst_copy_and_build
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: r...@gcc.gnu.org


template<bool, typename T>
struct enable_if
{
    typedef T type;
};

template<typename T>
struct enable_if<false, T>
{
};

template<typename, typename>
struct is_same
{
    static const bool value = false;
};

template<typename T>
struct is_same<T,T>
{
    static const bool value = true;
};

struct S
{
    template<typename T>
        static
        auto
        f(T t) -> typename enable_if<
            is_same<decltype(t.f()), decltype(t.f())>::value,
            decltype(t.f()) >::type
        { return t.f(); }


    template<typename T>
        static
        auto
        f(T t) -> typename enable_if<
            !is_same<decltype(t.f()), decltype(t.f())>::value,
            decltype(f(t)) >::type
        { return f(t); }

};

struct X {
    int f();
};


int main()
{
    X v;

    auto i = S::f(v);
}

ICEs with any of 4.4/4.5/4.6, didn't try 4.7


Program received signal SIGSEGV, Segmentation fault.
0x00000000004b8f74 in tsubst_copy_and_build (t=0x2aaaaaae3a18,
    args=0x2aaaab753aa0, complain=0, in_decl=0x0, function_p=0 '\000',
    integral_constant_expression_p=0 '\000')
    at ../../gcc-4.6.0-RC-20110321/gcc/cp/pt.c:13293
13293           tree r = tsubst_copy (t, args, complain, in_decl);


Seems to be an infinite recursion, possibly because the second overload of S::f
tries to instantiate itself recursively - the code is probably invalid

Reply via email to