1// RUN: %clang -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="pointer-overflow"
2// RUN: %clangxx -x c++ -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="pointer-overflow"
3
4#include <stdlib.h>
5
6int main(int argc, char *argv[]) {
7 char *base, *result;
8
9 base = (char *)0;
10 result = base + 0;
11 // CHECK-NOT: pointer-overflow
12
13 base = (char *)0;
14 result = base + 1;
15 // CHECK: pointer-overflow by 0x{{[[:xdigit:]]+$}}
16
17 base = (char *)1;
18 result = base - 1;
19 // CHECK: pointer-overflow by 0x{{[[:xdigit:]]+$}}
20
21 return 0;
22}
23

source code of compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c