1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s 2 3 using size_t = decltype(sizeof(int)); operator new(size_t,void * p)4void *operator new(size_t, void *p) { return p; } 5 6 struct myfunction { 7 union storage_t { 8 char buffer[100]; 9 size_t max_align; 10 } storage; 11 myfunctionmyfunction12 template <typename Func> myfunction(Func fn) { 13 new (&storage.buffer) Func(fn); 14 } 15 void operator()(); 16 }; 17 create_func()18myfunction create_func() { 19 int n; 20 auto c = [&n] {}; 21 return c; // expected-warning {{Address of stack memory associated with local variable 'n' is still referred to by a temporary object on the stack upon returning to the caller. This will be a dangling reference}} 22 } gh_66221()23void gh_66221() { 24 create_func()(); 25 } 26