synthetic tests: add ub.c

This commit is contained in:
Daniel Marjamäki 2016-11-03 14:51:18 +01:00
parent 0836b999cf
commit 506d1ed68d
2 changed files with 15 additions and 2 deletions

View File

@ -2,7 +2,7 @@ ifndef CC
CC=gcc CC=gcc
endif endif
all: controlflow.o data.o functions.o all: controlflow.o data.o functions.o ub.o
controlflow.o: controlflow.c controlflow.o: controlflow.c
$(CC) -c controlflow.c $(CC) -c controlflow.c
@ -13,5 +13,8 @@ data.o: data.c
functions.o: functions.c functions.o: functions.c
$(CC) -c functions.c $(CC) -c functions.c
ub.o: ub.c
$(CC) -c ub.c
clean: clean:
rm -rf controlflow.o data.o functions.o uninit.o rm -rf controlflow.o data.o functions.o ub.o

10
test/synthetic/ub.c Normal file
View File

@ -0,0 +1,10 @@
int buffer_overflow() { int x[10]; return x[100]; }
int division_by_zero() { return 100 / 0; }
int no_return() {}
int null_pointer() { int *p = 0; return *p; }
int *pointer_arithmetic() { static int buf[10]; return buf + 100; }
int shift_overrun(int x) { return x << 123; }
int shift_negative() { return -1 << 1; }
int signed_int_overrun() { int x = ~0; return x * 2; }
void string_literal() { *((char *)"hello") = 0; }
int uninit() { int x; return x + 2; }