1// RUN: %clang -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-C --implicit-check-not="pointer-overflow"
2// RUN: %clangxx -x c++ -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-CPP --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-C: pointer-overflow by 0x{{[[:xdigit:]]+$}}
12 // CHECK-CPP-NOT: pointer-overflow
13
14 base = (char *)0;
15 result = base + 1;
16 // CHECK: pointer-overflow by 0x{{[[:xdigit:]]+$}}
17
18 base = (char *)1;
19 result = base - 1;
20 // CHECK: pointer-overflow by 0x{{[[:xdigit:]]+$}}
21
22 return 0;
23}
24

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