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

            Bug ID: 92431
           Summary: ICE with spaceship in constexpr evaluation
           Product: gcc
           Version: 10.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
                CC: jason at gcc dot gnu.org
  Target Milestone: ---

This crashes when compiled with -std=gnu++2a:


#include <compare>

template<typename _Tp, typename _Up>
  concept op_cmp = requires(_Tp&& __t, _Up&& __u)
  {
    std::weak_ordering(static_cast<_Tp&&>(__t) <=> static_cast<_Up&&>(__u));
  };

struct Weak_order
{
  template<typename _Tp, typename _Up>
    constexpr std::weak_ordering
    operator()(_Tp&& __e, _Up&& __f) const
    {
      if constexpr (op_cmp<_Tp, _Up>)
        return static_cast<_Tp&&>(__e) <=> static_cast<_Up&&>(__f);
    }
};

constexpr Weak_order weak_order{};

auto o = weak_order(1, 2);




wo.cc:22:25:   in 'constexpr' expansion of
'weak_order.Weak_order::operator()<int, int>(1, 2)'
wo.cc:22:25: internal compiler error: in cxx_eval_constant_expression, at
cp/constexpr.c:5123
   22 | auto o = weak_order(1, 2);
      |                         ^
0x5d0fd7 cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:5123
0x88f898 cxx_bind_parameters_in_call
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:1424
0x88f898 cxx_eval_call_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:1921
0x892d5a cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:4924
0x893cbd cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:4995
0x89c27a cxx_eval_store_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:4254
0x893046 cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:5013
0x8916d3 cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:5025
0x892513 cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:5064
0x893da0 cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:5327
0x890adb cxx_eval_call_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:2072
0x892d5a cxx_eval_constant_expression
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:4924
0x895d8e cxx_eval_outermost_constant_expr
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:5868
0x89a24b maybe_constant_value(tree_node*, tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/constexpr.c:6138
0xa55490 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        /home/jwakely/src/gcc/gcc/gcc/cp/typeck2.c:858
0x8c952d check_initializer
        /home/jwakely/src/gcc/gcc/gcc/cp/decl.c:6718
0x8ebfdf cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        /home/jwakely/src/gcc/gcc/gcc/cp/decl.c:7634
0x99660e cp_parser_init_declarator
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:20727
0x9764b2 cp_parser_simple_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:13624
0x99e997 cp_parser_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:13322
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