Skip to content
Snippets Groups Projects
Commit 20045b16 authored by balliet's avatar balliet
Browse files

newdelete tests

Former-commit-id: 20661936f01cf152c81dc42105c9932f25c8ea1e
parent 090fb954
No related branches found
No related tags found
No related merge requests found
......@@ -420,6 +420,12 @@ c++_examples/newdel_broke4.cpp -text
c++_examples/newdel_broke5.cpp -text
c++_examples/newdel_broke6.cpp -text
c++_examples/newdel_broke7.cpp -text
c++_examples/newdelete1.cpp -text
c++_examples/newdelete2.cpp -text
c++_examples/newdelete3.cpp -text
c++_examples/newdelete4.cpp -text
c++_examples/newdelete5.cpp -text
c++_examples/newdelete6.cpp -text
c++_examples/spec2006_binaries/README -text
c++_examples/spec2006_binaries/dynamically_linked/README -text
c++_examples/spec2006_binaries/dynamically_linked/SPEC-benchmark-test.ini -text
......
......@@ -7,7 +7,8 @@ LD=DO_NOT_USE
.SUFFIXES: .o .c .cpp .stock .protected
exes=hanoi++.protected newdel.protected newdel_broke1.protected newdel_broke2.protected newdel_broke3.protected newdel_broke4.protected newdel_broke5.protected newdel_broke6.protected newdel_broke7.protected throw.protected
exes=hanoi++.protected newdel.protected newdel_broke1.protected newdel_broke2.protected newdel_broke3.protected newdel_broke4.protected newdel_broke5.protected newdel_broke6.protected newdel_broke7.protected throw.protected newdelete1.protected newdelete2.protected newdelete3.protected newdelete4.protected newdelete5.protected newdelete6.protected
all: env_check ${exes}
......
int main() {
int *x;
x = new int[1];
delete[] x; /* OK */
x = new int[1];
delete x; /* BAD */
return 0;
}
int main() {
int *x;
x = new int;
delete x; /* OK */
x = new int;
delete[] x; /* BAD */
return 0;
}
#include <cstdlib>
int main() {
int *x;
x = new int[1];
delete[] x; /* OK */
x = new int[1];
free(x); /* BAD */
return 0;
}
#include <cstdlib>
int main() {
int *x;
x = new int;
delete x; /* OK */
x = new int;
free(x); /* BAD */
return 0;
}
#include <cstdlib>
int main() {
int *x;
x = (int *) malloc(sizeof *x);
free(x); /* OK */
x = (int*) malloc(sizeof *x);
delete x; /* BAD */
return 0;
}
#include <cstdlib>
int main() {
int *x;
x = (int *) malloc(sizeof *x);
free(x); /* OK */
x = (int *) malloc(sizeof *x);
delete[] x; /* BAD */
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment