diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | UBasan-test.cpp | 19 |
2 files changed, 19 insertions, 4 deletions
@@ -1,7 +1,7 @@ CC1=clang++ CC2=g++ -CFLAGS_CLANG=-O0 -Wfatal-errors -Wall -Werror -Wextra -g3 -fsanitize=address,leak,undefined -Wpedantic -Wformat=2 -Wshadow -fno-common -std=c++2b -CFLAGS_GCC=-O0 -Wfatal-errors -Wall -Werror -Wextra -g3 -fsanitize=address,leak,undefined -Wpedantic -Wformat=2 -Wshadow -fno-common -std=c++2b -Wformat-truncation=2 -Wformat-overflow +CFLAGS_CLANG=-O0 -Wfatal-errors -Wall -Werror -Wextra -g3 -fsanitize=address,leak,undefined,float-divide-by-zero -Wpedantic -Wformat=2 -Wshadow -fno-common -std=c++2b +CFLAGS_GCC=-O0 -Wfatal-errors -Wall -Werror -Wextra -g3 -fsanitize=address,leak,undefined,float-divide-by-zero -Wpedantic -Wformat=2 -Wshadow -fno-common -std=c++2b -Wformat-truncation=2 -Wformat-overflow BINDIR=bin SRCS=$(wildcard *.cpp) OBJS_CLANG=$(patsubst %.cpp, $(BINDIR)/clang/%, $(SRCS)) diff --git a/UBasan-test.cpp b/UBasan-test.cpp index a2d68f5..1cbcfc7 100644 --- a/UBasan-test.cpp +++ b/UBasan-test.cpp @@ -5,11 +5,26 @@ /* * - * - * + * Found out about UBsanitizer so i just wanted to try it out! + * Some examples in here that trigger the sanitizer. Obviously not all examples. * */ int main () { + + int arr[] = {1,2,3,4,5,6,7,8,9,10}; + int *val = arr + 11; + std::cout << val << std::endl; + double a = 10; + std::cout << "Input a 0: " << std::endl; + std::cin >> a; + double b = 10 / a; + std::cout << b << std::endl; + + int c = 10; + std::cout << "Input a 0: " << std::endl; + std::cin >> c; + int d = 10 / c; + std::cout << d << std::endl; return 0; } |