Add regression test for 9534: False positive: Returning pointer to local variable 'x' that will be invalid when returning. (#2596)
This commit is contained in:
parent
8dd0a9241c
commit
8fd0839fea
|
@ -2301,6 +2301,16 @@ private:
|
|||
" return fred.s.c_str();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #9534
|
||||
check("struct A {\n"
|
||||
" int* x;\n"
|
||||
"};\n"
|
||||
"int* f(int i, std::vector<A>& v) {\n"
|
||||
" A& y = v[i];\n"
|
||||
" return &y.x[i];\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetimeFunction() {
|
||||
|
|
Loading…
Reference in New Issue