[Bug c++/126804] New: [contracts] parameter pack of non-reference type used as an argument to a function in a contract assertion ICEs

"waffl3x at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126804

            Bug ID: 126804
           Summary: [contracts] parameter pack of non-reference type used
                    as an argument to a function in a contract assertion
                    ICEs
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: waffl3x at gcc dot gnu.org
  Target Milestone: ---

https://godbolt.org/z/eYd9YMv16
```
bool take(int const&) { return true; }

template<typename... Args>
void f(Args... args)
  pre(take(args...)) {}

template void f(int);
```
during RTL pass: expand
<stdin>: In function 'void f(Args ...) [with Args = {int}]':
<stdin>:5:11: internal compiler error: in make_decl_rtl, at varasm.cc:1487
0x2cad2b0 internal_error(char const*, ...)
        ../../src/gcc/diagnostic-global-context.cc:787
0xa9c163 fancy_abort(char const*, int, char const*)
        ../../src/gcc/diagnostics/context.cc:1813
0x9a2a87 make_decl_rtl(tree_node*)
        ../../src/gcc/varasm.cc:1487
0x10e97fc expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../src/gcc/expr.cc:11752
0x10f61c7 expand_expr(tree_node*, rtx_def*, machine_mode, expand_modifier)
        ../../src/gcc/expr.h:323
0x10f61c7 expand_expr_addr_expr_1
        ../../src/gcc/expr.cc:9347
0x10f6865 expand_expr_addr_expr
        ../../src/gcc/expr.cc:9468
0x10e78bc expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../src/gcc/expr.cc:13065
0xf780f0 expand_normal(tree_node*)
        ../../src/gcc/expr.h:329
0xf780f0 precompute_register_parameters
        ../../src/gcc/calls.cc:1025
0xf7fb0f expand_call(tree_node*, rtx_def*, int)
        ../../src/gcc/calls.cc:3506
0x10e94c6 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../src/gcc/expr.cc:12816
0x10f6c2d store_expr(tree_node*, rtx_def*, int, bool, bool)
        ../../src/gcc/expr.cc:6830
0x10fa137 expand_assignment(tree_node*, tree_node*, bool)
        ../../src/gcc/expr.cc:6526
0x10fa137 expand_assignment(tree_node*, tree_node*, bool)
        ../../src/gcc/expr.cc:6015
0xf98694 expand_call_stmt
        ../../src/gcc/cfgexpand.cc:3233
0xf98694 expand_gimple_stmt_1
        ../../src/gcc/cfgexpand.cc:4273
0xf98694 expand_gimple_stmt
        ../../src/gcc/cfgexpand.cc:4420
0xf9a537 expand_gimple_basic_block
        ../../src/gcc/cfgexpand.cc:6537
0xf9c667 execute
        ../../src/gcc/cfgexpand.cc:7288

Also occurs in a postcondition, there are 2 other bugs that prevent
explicit instantiation from working here (in different ways) so this
case is slightly different.
https://godbolt.org/z/esfEGa9zj
```
bool take(int const&) { return true; }

template<typename... Args>
void f(Args const... args)
  post(take(args...)) {}

void go()
{ f(42); }
```
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.