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

            Bug ID: 96905
           Summary: ICE with consteval function: internal compiler error:
                    in cp_gimplify_expr, at cp/cp-gimplify.c:827
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

template<typename Rep>
struct duration
{
  static consteval int
  gcd(int m, int n) noexcept
  {
    while (m != 0 && n != 0)
    {
      int rem = m % n;
      m = n;
      n = rem;
    }
    return m + n;
  }
};

template class duration<int>;

Compiled with -std=gnu++20 this ICEs:

ice.C: In static member function 'static consteval int duration<Rep>::gcd(int,
int) [with Rep = int]':
ice.C:7:5: internal compiler error: in cp_gimplify_expr, at
cp/cp-gimplify.c:827
    7 |     while (m != 0 && n != 0)
      |     ^~~~~
0x603457 cp_gimplify_expr(tree_node**, gimple**, gimple**)
        /home/jwakely/src/gcc/gcc/gcc/cp/cp-gimplify.c:827
0xd3f160 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:13571
0xd435c6 gimplify_stmt(tree_node**, gimple**)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:6822
0xd40e43 gimplify_statement_list
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:1856
0xd40e43 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:14106
0xd435c6 gimplify_stmt(tree_node**, gimple**)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:6822
0xd44291 gimplify_bind_expr
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:1411
0xd40209 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:13863
0xd4dcdc gimplify_stmt(tree_node**, gimple**)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:6822
0xd4dcdc gimplify_and_add(tree_node*, gimple**)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:486
0x8de1d3 gimplify_must_not_throw_expr
        /home/jwakely/src/gcc/gcc/gcc/cp/cp-gimplify.c:577
0x8de1d3 cp_gimplify_expr(tree_node**, gimple**, gimple**)
        /home/jwakely/src/gcc/gcc/gcc/cp/cp-gimplify.c:717
0xd3f160 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:13571
0xd58ac7 gimplify_stmt(tree_node**, gimple**)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:6822
0xd58ac7 gimplify_body(tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:14898
0xd58efd gimplify_function_tree(tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/gimplify.c:15052
0xb9f997 cgraph_node::analyze()
        /home/jwakely/src/gcc/gcc/gcc/cgraphunit.c:671
0xba29b7 analyze_functions
        /home/jwakely/src/gcc/gcc/gcc/cgraphunit.c:1235
0xba357d symbol_table::finalize_compilation_unit()
        /home/jwakely/src/gcc/gcc/gcc/cgraphunit.c:2991
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to