Bug 48285 - [C++0x] ICE in tsubst_copy_and_build
Summary: [C++0x] ICE in tsubst_copy_and_build
Status: RESOLVED DUPLICATE of bug 48969
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-25 13:13 UTC by Jonathan Wakely
Modified: 2011-05-22 19:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2011-03-25 13:13:01 UTC
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
Comment 1 Jason Merrill 2011-05-22 19:04:01 UTC
Same issue as 48969.

*** This bug has been marked as a duplicate of bug 48969 ***