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

            Bug ID: 111529
           Summary: ICE on bool conversion in an unrolled loop condition
                    inside template lambda nested in another template
                    scope
           Product: gcc
           Version: 13.2.0
               URL: https://godbolt.org/z/q64oM6bre
            Status: UNCONFIRMED
          Keywords: c++-lambda, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugreport0 at proton dot me
  Target Milestone: ---

template <int x>
void f() {
  [](auto c) {
    #pragma GCC unroll 9
    for (int i = c; i; --i) {
    }
  };
}

int main() {
  f<0>();
}


compiles with -std=c++14 but with -std=c++17 generates


<source>: In instantiation of 'void f() [with int x = 0]':
<source>:11:7:   required from here
<source>:5:19: internal compiler error: unexpected expression '(bool)i' of kind
implicit_conv_expr
    5 |     for (int i = c; i; --i) {
      |                   ^
0x1ce7bde internal_error(char const*, ...)
        ???:0
0x8f1d4c finish_for_cond(tree_node*, tree_node*, bool, unsigned short)
        ???:0
0x8d0054 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x8beb17 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x8d993b instantiate_pending_templates(int)
        ???:0
0x7d9f35 c_parse_final_cleanups()
        ???:0
0x98c608 c_common_parse_file()
        ???:0


Making any explicit conversion on the counter inside the condition breaks
compilation with -std=c++14 too.

Reply via email to