[Bug c++/105743] New: Bogus unused but set lambda warning

johelegp at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu May 26 17:04:12 GMT 2022


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

            Bug ID: 105743
           Summary: Bogus unused but set lambda warning
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/xq16xac15.

```C++
void f(auto x) { x(0); }
void g() {
  static constexpr auto h = [](...) { };
  f([](auto x) { h(x); });
}
```

```
<source>: In function 'void g()':
<source>:3:25: warning: variable 'h' set but not used
[-Wunused-but-set-variable]
    3 |   static constexpr auto h = [](...) { };
      |                         ^
```

Arguably, `h(x)` could perform ADL on `x`. But perhaps it'd be better to stay
silent, like the other compilers.


More information about the Gcc-bugs mailing list