Issue 110080
Summary clang++ outputs wrong warning for if constexpr and lambda capture combination
Labels clang
Assignees
Reporter faithandbrave
    ```cpp
struct A {
    static constexpr bool value = false;
};

struct B {
 static constexpr bool value = true;
};

void h() {}

template <class T>
struct C {
    void f() {
        auto lambda = [this] {
            if constexpr (T::value) {
                g();
 }
            else {
                h();
            }
 };
        lambda();
    }

    void g() {}
};

int main()
{
    C<A>{}.f();
 C<B>{}.f();
}
```

outputs:

```
prog.cc:14:24: warning: lambda capture 'this' is not used [-Wunused-lambda-capture]
   14 | auto lambda = [this] {
      |                        ^
prog.cc:30:12: note: in instantiation of member function 'C<A>::f' requested here
   30 | C<A>{}.f();
      |            ^
1 warning generated.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to