https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122100
Bug ID: 122100
Summary: -Wunused-but-set-variable false positive of static
variable used by a generic lambda
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: olaf.krzikalla at dlr dot de
Target Milestone: ---
Very probably related to #114450, but more generalized: bogus warning about
unused static variable inside generic lambda:
```
#include <iostream>
void bar(auto&& fn)
{
fn(std::cout);
}
int main()
{
static const int i = 11;
bar([&](auto& stream) { stream << i; });
}
```
https://godbolt.org/z/78TrqzGz3
Happens in all versions up to trunk.