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

            Bug ID: 92583
           Summary: internal compiler error: in tsubst_copy, at
                    cp/pt.c:15552
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fiesh at zefix dot tv
  Target Milestone: ---

The following code leads to an internal compiler error with gcc 8, 9, and
trunk:

template <int> struct a {};
template <typename> using b = int;
template <typename d, d> struct e {};
template <typename d, d g> using h = e<d, __integer_pack(g)...>;
template <typename j, typename k, k... index> void apply(j f, e<k, index...>) {
  (f(a<index>{}), ...);
}
template <auto l, typename j> void m(j f) {
  using k = b<decltype(l)>;
  using n = h<k, l>;
  apply(f, n{});
}
template <int, int c> void o() {
  auto p = [](auto i) {
    if constexpr (a<i>{})
      ;
  };
  m<c>(p);
}
auto q() { o<0, 1>; }




% g++ -std=c++17 -c h.ii
h.ii: In instantiation of ‘o() [with int <anonymous> = 0; int c =
1]::<lambda(auto:1)> [with auto:1 = a<0>]’:
h.ii:6:5:   required from ‘void apply(j, e<k, index ...>) [with j = o() [with
int <anonymous> = 0; int c = 1]::<lambda(auto:1)>; k = int; k ...index = {0}]’
h.ii:11:8:   required from ‘void m(j) [with auto l = 1; j = o() [with int
<anonymous> = 0; int c = 1]::<lambda(auto:1)>]’
h.ii:18:7:   required from ‘void o() [with int <anonymous> = 0; int c = 1]’
h.ii:20:19:   required from here
h.ii:15:5: internal compiler error: in tsubst_copy, at cp/pt.c:15552
   15 |     if constexpr (a<i>{})
      |     ^~
0x58f8a4 tsubst_copy
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:15552
0x6c7fc0 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:19486
0x6d14d5 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:18242
0x6d14d5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:17918
0x6d836a tsubst_template_args
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:12574
0x6db018 tsubst_aggr_type
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:12771
0x6cbe11 tsubst(tree_node*, tree_node*, int, tree_node*)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:14460
0x6c8299 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:19373
0x6d14d5 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:18242
0x6d14d5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:17918
0x6d0720 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:17270
0x6d0629 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:17325
0x6d0629 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:17325
0x6d0629 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:17325
0x6cfd2a instantiate_decl(tree_node*, bool, bool)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/pt.c:24792
0x638f52 maybe_instantiate_decl
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/decl2.c:5300
0x638f52 maybe_instantiate_decl
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/decl2.c:5284
0x63ac08 mark_used(tree_node*, int)
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/decl2.c:5456
0x5dc7d8 build_over_call
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/call.c:8677
0x5df7b6 build_op_call_1
        /usr/src/debug/sys-devel/gcc-9.2.0-r2/gcc-9.2.0/gcc/cp/call.c:4778
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.

Reply via email to