From e14809baa8fa879009a079e1b1de18dc395283af Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 17 Jun 2019 03:55:19 -0700 Subject: [PATCH] [pulse] fix temporaries test code Summary: A test was claiming to be ok but wasn't. Reviewed By: mbouaziz Differential Revision: D15695944 fbshipit-source-id: 58772a793 --- .../cpp/pulse/use_after_destructor.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/infer/tests/codetoanalyze/cpp/pulse/use_after_destructor.cpp b/infer/tests/codetoanalyze/cpp/pulse/use_after_destructor.cpp index 151c74d36..b285fb733 100644 --- a/infer/tests/codetoanalyze/cpp/pulse/use_after_destructor.cpp +++ b/infer/tests/codetoanalyze/cpp/pulse/use_after_destructor.cpp @@ -22,6 +22,11 @@ struct S { // operator= is called ~S() { delete f; } + + void reinit(S s) { + f = new int; + *f = *(s.f); + } }; // destructor called at end of function, no issues @@ -34,7 +39,14 @@ void nested_scope_destructor_ok() { int reinit_after_explicit_destructor_ok() { S s(1); s.~S(); - s = S(2); + s.reinit(S(2)); + return *s.f; +} + +int FN_reinit_after_explicit_destructor_bad() { + S s(1); + s.~S(); + s = S(2); // a temporary is created then operator= is called return *s.f; }