https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120128
Bug ID: 120128
Summary: Excesive output in recursive lambda composition, that
can lead to g++:fatal error
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mario.rodriguezb1 at um dot es
Target Milestone: ---
The initial program returns excesive ouput that has to be truncated by gcc
bolt, and when removing ```auto``` a ```g++: fatal error``` arises
```
#include <iostream>
auto sum(const int n, auto f) {
if(n == 0) return f(2 + n);
return sum(n - 1, [&](auto i) { return f(n, i); });
}
int main() { sum(2, [](auto i, auto n) { return ns::n++; }); return 0; }
```
To reproduce excesive output:
https://gcc.godbolt.org/z/MqMbPzEbP
To reproduce g++: fatal error:
https://gcc.godbolt.org/z/M1Y6ePGTE