1 // RUN: %clangxx -fsanitize=pointer-overflow %s -o %t
2 // RUN: %run %t 2 2>&1 | FileCheck %s --implicit-check-not="runtime error:" --check-prefix=ERR2
3 // RUN: %run %t 1 2>&1 | FileCheck %s --implicit-check-not="runtime error:" --check-prefix=ERR1
4 // RUN: %run %t 0 2>&1 | FileCheck %s --implicit-check-not="runtime error:" --check-prefix=SAFE
5 // RUN: %run %t -1 2>&1 | FileCheck %s --implicit-check-not="runtime error:" --check-prefix=SAFE
6 // RUN: %run %t -2 2>&1 | FileCheck %s --implicit-check-not="runtime error:" --check-prefix=SAFE
12 int main(int argc
, char *argv
[]) {
13 // SAFE-NOT: runtime error
14 // ERR2: runtime error: pointer index expression with base {{.*}} overflowed to
15 // ERR2: runtime error: pointer index expression with base {{.*}} overflowed to
16 // ERR1: runtime error: applying non-zero offset to non-null pointer 0x{{.*}} produced null pointer
17 // ERR1: runtime error: applying non-zero offset to non-null pointer 0x{{.*}} produced null pointer
19 char *p
= (char *)(UINTPTR_MAX
);
21 printf("%p\n", p
+ atoi(argv
[1]));
23 char *q
= (char *)(UINTPTR_MAX
);
25 printf("%p\n", p
- (-atoi(argv
[1])));