[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / clang / docs / analyzer / checkers / newdelete_example.cpp
blobb26ddcb3d964e8d99fffc28dc69263cec359bd4c
1 void f(int *p);
3 void testUseMiddleArgAfterDelete(int *p) {
4 delete p;
5 f(p); // warn: use after free
8 class SomeClass {
9 public:
10 void f();
13 void test() {
14 SomeClass *c = new SomeClass;
15 delete c;
16 c->f(); // warn: use after free
19 void test() {
20 int *p = (int *)__builtin_alloca(sizeof(int));
21 delete p; // warn: deleting memory allocated by alloca
24 void test() {
25 int *p = new int;
26 delete p;
27 delete p; // warn: attempt to free released
30 void test() {
31 int i;
32 delete &i; // warn: delete address of local
35 void test() {
36 int *p = new int[1];
37 delete[] (++p);
38 // warn: argument to 'delete[]' is offset by 4 bytes
39 // from the start of memory allocated by 'new[]'