From 94c2cd1d3be41e6e166241154cd0875de0a4c9ed Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Wed, 4 Apr 2018 09:36:34 -0700 Subject: [PATCH] [ownership] tests for pointer arithmetic Reviewed By: jeremydubreil Differential Revision: D7495530 fbshipit-source-id: 0685772 --- infer/tests/codetoanalyze/cpp/ownership/basics.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/infer/tests/codetoanalyze/cpp/ownership/basics.cpp b/infer/tests/codetoanalyze/cpp/ownership/basics.cpp index 2e07dda42..059af3ef6 100644 --- a/infer/tests/codetoanalyze/cpp/ownership/basics.cpp +++ b/infer/tests/codetoanalyze/cpp/ownership/basics.cpp @@ -8,6 +8,7 @@ */ #include +#include struct Aggregate { int i; @@ -73,3 +74,15 @@ int multiple_invalidations_loop_bad(int n, int* ptr) { } return *ptr; } + +Aggregate* pointer_arithmetic_ok(Aggregate* a) { + a->~Aggregate(); + a++; + return a; +} + +void iterator_pointer_arithmetic_ok(std::vector v) { + for (auto it = v.begin(); it != v.end(); ++it) { + it->~Aggregate(); + } +}