Make test more lenient for custom clang version strings
[llvm-project.git] / compiler-rt / test / asan / TestCases / wild_pointer.cpp
blob8969a285e565e69531b16db89cea85c7504e0284
1 // RUN: %clangxx_asan %s -o %t
2 // RUN: not %run %t 2>&1 | FileCheck %s
3 // REQUIRES: asan-64-bits
5 #include <inttypes.h>
6 #include <stdarg.h>
7 #include <stdint.h>
8 #include <stdio.h>
9 #include <string.h>
11 int main() {
12 char *p = new char;
13 char *dest = new char;
14 const size_t offset = 0x4567890123456789;
16 // The output here needs to match the output from the sanitizer runtime,
17 // which includes 0x and prints hex in lower case.
19 // On Windows, %p omits %0x and prints hex characters in upper case,
20 // so we use PRIxPTR instead of %p.
21 fprintf(stderr, "Expected bad addr: %#" PRIxPTR "\n",
22 reinterpret_cast<uintptr_t>(p + offset));
23 // Flush it so the output came out before the asan report.
24 fflush(stderr);
26 memmove(dest, p, offset);
27 return 0;
30 // CHECK: Expected bad addr: [[ADDR:0x[0-9,a-f]+]]
31 // CHECK: AddressSanitizer: unknown-crash on address [[ADDR]]
32 // CHECK: Address [[ADDR]] is a wild pointer inside of access range of size 0x4567890123456789