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

            Bug ID: 93862
           Summary: ICE on static_cast of rvalue-reference-to-array of
                    unknown bound [P0338] to its known static bound
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wjwray at gmail dot com
  Target Milestone: ---

https://wandbox.org/permlink/ZaGwU3l7WbEc91Hw

1st line below an rvalue array binds, with lifetime extension,
to an (rvalue-)reference-to-array of unknown bound (by P0388),
so decltype(intu_rvref) is int(&&)[]

2nd line attempts to static_cast to its correct static type,
as an lvalue-ref; this is rejected, it should be accepted.

3rd line attempts to static_cast to rvalue-ref of correct static 
at which point the compiler crashes (stack trace below):

    int(&&intu_rvref)[]{1,2,3,4};  // (1) OK since P0388

 // int(&int4_lvref)[4] = static_cast<int(&)[4]>(intu_rvref); // (2)
 // error: invalid 'static_cast' from type 'int []' to type 'int (&)[4]'

    int(&&int4_rvref)[4] = static_cast<int(&&)[4]>(intu_rvref); // (3) ICE


stack trace

prog.cc:6:58: internal compiler error: Segmentation fault
    6 | int(&&int4_rvref)[4] = static_cast<int(&&)[4]>(intu_rvref); // ICE
      |                                                          ^
0xc173ef crash_signal
        ../../source/gcc/toplev.c:328
0xe583b4 tree_nop_conversion
        ../../source/gcc/tree.c:12663
0xe583b4 tree_nop_conversion
        ../../source/gcc/tree.c:12652
0xe583b4 tree_strip_nop_conversions(tree_node*)
        ../../source/gcc/tree.c:12694
0x63284e potential_constant_expression_1
        ../../source/gcc/cp/constexpr.c:7381
0x6337d2 potential_constant_expression_1(tree_node*, bool, bool, bool, int)
        ../../source/gcc/cp/constexpr.c:7981
0x6337d2 potential_constant_expression(tree_node*)
        ../../source/gcc/cp/constexpr.c:7990
0x6779ac cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../source/gcc/cp/decl.c:7550
0x6f96c0 cp_parser_init_declarator
        ../../source/gcc/cp/parser.c:20828
0x6dc7c0 cp_parser_simple_declaration
        ../../source/gcc/cp/parser.c:13678
0x701a82 cp_parser_declaration
        ../../source/gcc/cp/parser.c:13377
0x7021a4 cp_parser_translation_unit
        ../../source/gcc/cp/parser.c:4731
0x7021a4 c_parse_file()
        ../../source/gcc/cp/parser.c:43709
0x7c9aab c_common_parse_file()
        ../../source/gcc/c-family/c-opts.c:1186
Please submit a full bug report

Reply via email to