From 6f5cb512db9694dcd86ebf5fc57e91d765b28a4d Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 17 Jun 2019 03:55:23 -0700 Subject: [PATCH] [pulse] add example of FN in const-ref-bound temporary Summary: This one isn't caught because we don't destruct temporaries that are bound to a const reference. According to the C++ standard these should get destroyed when the const reference gets destroyed but instead we just don't destroy them for now. Reviewed By: mbouaziz Differential Revision: D15760209 fbshipit-source-id: 32c935ec0 --- .../codetoanalyze/cpp/pulse/temporaries.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/infer/tests/codetoanalyze/cpp/pulse/temporaries.cpp b/infer/tests/codetoanalyze/cpp/pulse/temporaries.cpp index c72afacd8..7cbf6ee06 100644 --- a/infer/tests/codetoanalyze/cpp/pulse/temporaries.cpp +++ b/infer/tests/codetoanalyze/cpp/pulse/temporaries.cpp @@ -59,4 +59,21 @@ int call_mk_UniquePtr_A_copy_object_ok() { return a.s_; } +void temporary_in_conditional_ok() { + while (true) { + int x = true ? 0 : A(4).s_; + } +} + +void call_mk_UniquePtr_A_get_field_ok() { int x = A().s_; } + +int FN_bind_temporary_to_const_bad() { + A* a_ptr; + { + const UniquePtr& local = mk_UniquePtr_A(); + a_ptr = local.get(); + } + return a_ptr->s_; +} + } // namespace temporaries