Files
clang-p2996/compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
Igor Kudrin 84c4efbc6d [ubsan-minimal] Report the address of an error
This implements a FIXME in the runtime library and adds printing the
address at the end of the message as "by 0x123abc". The buffer for the
message is allocated on the stack in a handler, so the stack memory
consumption is slightly increased. No additional external dependencies
are added.

Differential revision: https://reviews.llvm.org/D131914
2022-09-05 14:18:25 +04:00

24 lines
740 B
C

// RUN: %clang -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-C --implicit-check-not="pointer-overflow"
// 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"
#include <stdlib.h>
int main(int argc, char *argv[]) {
char *base, *result;
base = (char *)0;
result = base + 0;
// CHECK-C: pointer-overflow by 0x{{[[:xdigit:]]+$}}
// CHECK-CPP-NOT: pointer-overflow
base = (char *)0;
result = base + 1;
// CHECK: pointer-overflow by 0x{{[[:xdigit:]]+$}}
base = (char *)1;
result = base - 1;
// CHECK: pointer-overflow by 0x{{[[:xdigit:]]+$}}
return 0;
}