mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 14:26:06 +00:00

Reapplying changes from https://github.com/llvm/llvm-project/pull/125638 after buildbot failures. Buildbot failures fixed in 029e7e98dc9956086adc6c1dfb0c655a273fbee6, latest commit on this PR. It was a problem with a declared class member with same name as its type. Sorry!
26 lines
774 B
C++
26 lines
774 B
C++
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
|
|
|
|
using size_t = decltype(sizeof(int));
|
|
void *operator new(size_t, void *p) { return p; }
|
|
|
|
struct myfunction {
|
|
union storage_t {
|
|
char buffer[100];
|
|
size_t max_align;
|
|
} storage;
|
|
|
|
template <typename Func> myfunction(Func fn) {
|
|
new (&storage.buffer) Func(fn);
|
|
}
|
|
void operator()();
|
|
};
|
|
|
|
myfunction create_func() {
|
|
int n;
|
|
auto c = [&n] {};
|
|
return c; // expected-warning {{Address of stack memory associated with local variable 'n' returned to caller}} 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}}
|
|
}
|
|
void gh_66221() {
|
|
create_func()();
|
|
}
|