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

--- Comment #3 from Ivan Lazaric <ivan.lazaric.gcc at gmail dot com> ---
Additional example of I think valid code:
```cpp
int main() {
  int x = 3;
  auto lambda = [&, &x] pre(x > 0) {};
  lambda();
}
```

I think I rebuilt with your patch, and am seeing an ICE on this:
```
epoll_bug.cpp: In function 'int main()':
epoll_bug.cpp:3:22: warning: explicit by-reference capture of 'x' redundant
with by-reference capture default
    3 |   auto lambda = [&, &x] pre(x > 0) {};
      |                      ^
epoll_bug.cpp: In lambda function:
epoll_bug.cpp:3:31: internal compiler error: in gimplify_var_or_parm_decl, at
gimplify.cc:3426
    3 |   auto lambda = [&, &x] pre(x > 0) {};
      |                             ~~^~~
0x21f867b internal_error(char const*, ...)
       
/home/ilazaric/repos/ALL/submodules/gcc/gcc/diagnostic-global-context.cc:787
0x7af099 fancy_abort(char const*, int, char const*)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/diagnostics/context.cc:1823
0x778aff gimplify_var_or_parm_decl
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:3426
0xd399e7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:20946
0xd3a930 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:20600
0xd395f1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:21304
0xd47e10 gimplify_cond_expr
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:5673
0xd3abef gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:20433
0xd4cc18 gimplify_stmt(tree_node**, gimple**)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:8679
0xd4cc18 gimplify_bind_expr
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:1689
0xd39e5f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:20680
0xd3a615 gimplify_stmt(tree_node**, gimple**)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:8679
0xd3a615 gimplify_statement_list
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:2294
0xd3a615 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:20930
0xd3f02f gimplify_stmt(tree_node**, gimple**)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:8679
0xd3f02f gimplify_body(tree_node*, bool)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:21786
0xd3f449 gimplify_function_tree(tree_node*)
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/gimplify.cc:21995
0xb5e667 cgraph_node::analyze()
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/cgraphunit.cc:691
0xb60c97 analyze_functions
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/cgraphunit.cc:1270
0xb61956 symbol_table::finalize_compilation_unit()
        /home/ilazaric/repos/ALL/submodules/gcc/gcc/cgraphunit.cc:2593
/opt/GCC/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/cc1plus -quiet -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE epoll_bug.cpp -quiet -dumpdir a- -dumpbase
epoll_bug.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++26
-fcontracts -o /tmp/cc540vR5.s
```

The warning is also interesting

Reply via email to