https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126990
Bug ID: 126990
Summary: ICE in extract_ops_from_tree, at gimple-expr.cc
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: s.kimura.h41104 at gmail dot com
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/v3PE4fv4M
Reproducer:
```
template <typename Iter, typename Pred>
inline Iter foo(Iter first, Iter last, Pred pred) {
#pragma GCC unroll 4
#pragma GCC novector
while (first != last && !pred(*first) //)
++first;
return first;
}
short *bar(short *p) {
auto pred = [](short x) { return x == 42; };
return foo(p, p + 1024, pred);
}
```
Backtrace:
<source>: In function 'Iter foo(Iter, Iter, Pred)':
<source>:6:11: error: expected ')' before 'first' [-Wtemplate-body]
6 | ++first;
| ^~~~~
| )
<source>:5:11: note: to match this '('
5 | while (first != last && !pred(*first) //)
| ^
<source>: In instantiation of 'Iter foo(Iter, Iter, Pred) [with Iter = short
int*; Pred = bar(short int*)::<lambda(short int)>]':
<source>:12:13: required from here
12 | return foo(p, p + 1024, pred);
| ~~~^~~~~~~~~~~~~~~~~~~
<source>:5:34: error: lvalue required as increment operand
5 | while (first != last && !pred(*first) //)
| ~~~~^~~~~~~~
during GIMPLE pass: cfg
<source>: In function 'Iter foo(Iter, Iter, Pred) [with Iter = short int*; Pred
= bar(short int*)::<lambda(short int)>]':
<source>:2:13: internal compiler error: in extract_ops_from_tree, at
gimple-expr.cc:557
2 | inline Iter foo(Iter first, Iter last, Pred pred) {
| ^~~
0x2beb468 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2be00ab internal_error(char const*, ...)
???:0
0xb4805c fancy_abort(char const*, int, char const*)
???:0
0x118c400 gimple_build_assign(tree_node*, tree_node*)
???:0
This ICE goes back to gcc-15:
https://godbolt.org/z/xMa39fYqY