cppcheck: commit 5cb3aac
built with: make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes
$ cppcheck main.cpp
Checking main.cpp ...
main.cpp:15:12: error: Using pointer to local variable 'v' that may be invalid. [invalidContainer]
delete b;
^
main.cpp:12:12: note: Pointer to container is created here.
A *b = v.back();
^
main.cpp:13:5: note: After calling 'pop_back', iterators or references to the container's data may be invalid .
v.pop_back();
^
main.cpp:9:22: note: Variable created here.
std::vector<A *> v;
^
main.cpp:15:12: note: Using pointer to local variable 'v' that may be invalid.
delete b;
^
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
output:
cppcheck: commit 5cb3aac
built with: make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes
Thanks! I created this ticket: https://trac.cppcheck.net/ticket/9796