Issue 182291
Summary [LifetimeSafety] Wrong suggestion in 'this' capturing lambda
Labels false-positive, clang:temporal-safety
Assignees
Reporter usx95
    ```cpp
#include <iostream>
#include <string>
#include <string_view>
struct S {
 std::string s;
    void foo() {
        auto x = [&]() { 
 return s.size() > 0 ? 
                this->s.data() :
 s.data();
        };
 }
};
```

https://godbolt.org/z/jj5oYPxMh

Lifetimebound suggestion:
```
<source>:7:23: warning: implicit this in intra-TU function should be marked [[clang::lifetimebound]] [-Wlifetime-safety-intra-tu-suggestions]
    7 |         auto x = [&]() { 
 |                  ~    ^
      | [[clang::lifetimebound]]
<source>:8:20: note: param returned here
    8 | return s.size() > 0 ? 
      |                    ^~~~~~~~~~~~~~
 9 |                 this->s.data() :
      | ~~~~~~~~~~~~~~~~
   10 |                 s.data();
      | ~~~~~~~~
1 warning generated.
Compiler returned: 0
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to