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

            Bug ID: 85668
           Summary: ICE with substitution failure
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: miguel.ojeda.sandonis at gmail dot com
  Target Milestone: ---

The following input causes an ICE starting with GCC 4.9 until trunk, on
-std=c++{14,17,2a}.

    template <int>
    using V = void;

    template <typename F, typename T>
    auto f1(F f, T v) -> decltype(f(v))
    {
    }

    void f2(int p)
    {
        f1([](auto x) -> V<decltype(x)::y(p)> {}, 0);
    }

GCC trunk reports:

    x.cc: In substitution of 'template<class auto:1> f2(int)::<lambda(auto:1)>
[with auto:1 = int]':
    x.cc:5:32:   required by substitution of 'template<class F, class T>
decltype (f(v)) f1(F, T) [with F = f2(int)::<lambda(auto:1)>; T = int]'
    x.cc:11:48:   required from here
    x.cc:11:39: internal compiler error: in tsubst_copy, at cp/pt.c:15325
         f1([](auto x) -> V<decltype(x)::y(p)> {}, 0);
                                           ^
    0x7a2545 tsubst_copy
            ../../gcc/gcc/cp/pt.c:15325
    0x7a3c93 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
            ../../gcc/gcc/cp/pt.c:18843
    0x7a62eb tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
            ../../gcc/gcc/cp/pt.c:18962
    0x7a52bb tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*,
bool, bool)
            ../../gcc/gcc/cp/pt.c:18264
    0x7990ee tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
            ../../gcc/gcc/cp/pt.c:17412
    0x7bd710 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
            ../../gcc/gcc/cp/pt.c:11405
    0x7bd710 tsubst_template_arg
            ../../gcc/gcc/cp/pt.c:11416
    0x7c5eba tsubst_template_args
            ../../gcc/gcc/cp/pt.c:12440
    0x7bb3e7 tsubst(tree_node*, tree_node*, int, tree_node*)
            ../../gcc/gcc/cp/pt.c:14604
    0x7bb731 tsubst(tree_node*, tree_node*, int, tree_node*)
            ../../gcc/gcc/cp/pt.c:14221
    0x7cd52c tsubst_function_type
            ../../gcc/gcc/cp/pt.c:13979
    0x7bae75 tsubst(tree_node*, tree_node*, int, tree_node*)
            ../../gcc/gcc/cp/pt.c:14743
    0x7c69dc tsubst_function_decl
            ../../gcc/gcc/cp/pt.c:12907
    0x7ca178 tsubst_decl
            ../../gcc/gcc/cp/pt.c:13307
    0x7bb417 tsubst(tree_node*, tree_node*, int, tree_node*)
            ../../gcc/gcc/cp/pt.c:14195
    0x7b8afa instantiate_template_1
            ../../gcc/gcc/cp/pt.c:19215
    0x7b8afa instantiate_template(tree_node*, tree_node*, int)
            ../../gcc/gcc/cp/pt.c:19271
    0x7d1813 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
            ../../gcc/gcc/cp/pt.c:19633
    0x601961 add_template_candidate_real
            ../../gcc/gcc/cp/call.c:3179
    0x6025cb add_template_candidate
            ../../gcc/gcc/cp/call.c:3261

Live example:

    https://godbolt.org/g/HNEuE8

Reply via email to