================
@@ -268,4 +268,14 @@ struct true_type {
 template<class T> struct is_pointer : false_type {};
 template<class T> struct is_pointer<T*> : true_type {};
 template<class T> struct is_pointer<T* const> : true_type {};
+
+template<class> class function;
+template<class R, class... Args>
+class function<R(Args...)> {
+public:
+  template<class F> function(F) {}
+  template<class F> function& operator=(F) { return *this; }
----------------
aeft wrote:

Added both tests.

```cpp
std::function<void()> copy_assign() {
  int x;
  std::function<void()> f = [&x]() { (void)x; }; // expected-warning {{address 
of stack memory is returned later}}
  std::function<void()> f2 = []() {};
  f2 = f;
  return f2; // expected-note {{returned here}}
}

// FIXME: False negative. std::move's lifetimebound handling in
// `handleFunctionCall` only flows the outermost origin, missing inner origins
// that carry the lambda's loans.
std::function<void()> move_assign() {
  int x;
  std::function<void()> f = [&x]() { (void)x; }; // Should warn.
  std::function<void()> f2 = []() {};
  f2 = std::move(f);
  return f2;
}
```

move assign has FN. This seems an existing limitation. e.g., 
https://godbolt.org/z/rETxncchf
```cpp
int* test2() {
  int x;
  int* f = &x; // Should warn.
  int* a;
  a = std::move(f);
  return a;
}
```

cc @usx95 

https://github.com/llvm/llvm-project/pull/191123
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to