try to make synthetic tests more explicit

This commit is contained in:
Daniel Marjamäki 2016-11-04 19:32:42 +01:00
parent 13bfe873f6
commit 8e8194ee0f
3 changed files with 15 additions and 15 deletions

View File

@ -10,7 +10,7 @@ int getValue(void); // unknown int value
// -------------------------------------
void arg_in_if(int a) {
if (a>=100)
if (a==100)
buf[a] = 0; // BUG
}

View File

@ -2,21 +2,21 @@
int TestData[100];
void test_function_par1(int par) {
TestData[par] = 0;
void function_par_not_dependant(int par) {
TestData[par] = 0; // BUG
}
void test_function_par2(int x, int y) {
if (x < 123)
TestData[y] = 0;
void function_par_dependant(int x, int y) {
if (x < 10)
TestData[y] = 0; // BUG
}
void call(int x) {
test_function_par1(1000);
test_function_par2(x, x < 1000 ? 10 : 1000);
function_par_not_dependant(1000);
function_par_dependant(0, 1000);
}
int getLargeIndex() { return 1000; }
void test_function_return() {
TestData[getLargeIndex()] = 0;
TestData[getLargeIndex()] = 0; // BUG
}

View File

@ -1,12 +1,12 @@
int buffer_overflow() { int x[10]; return x[100]; }
int dead_pointer(int a) { int *p=&a; if (a) { int x; p = &x; } return *p; }
int buffer_overflow() { int x[10]={0}; return x[100]; }
int dead_pointer(int a) { int *p=&a; if (a) { int x=0; p = &x; } return *p; }
int division_by_zero() { return 100 / 0; }
int float_overflow() { float f=1E100; return f; }
void negative_size(int sz) { if (sz < 0) { int buf[sz]; } }
int no_return() {}
int null_pointer() { int *p = 0; return *p; }
int *pointer_arithmetic() { static int buf[10]; return buf + 100; }
char pointer_overflow() { static int buf[10]; return buf; }
char pointer_overflow() { static int buf[10]; return (int*)buf; }
int pointer_subtraction() { char a[10]; char b[10]; return b-a; }
int pointer_comparison() { char a[10]; char b[10]; return b<a; }
int shift_overrun(int x) { return x << 123; }