| 1 | // RUN: %clangxx_asan %s -o %t |
| 2 | // RUN: not %run %t 2>&1 | FileCheck %s |
| 3 | // REQUIRES: asan-64-bits |
| 4 | |
| 5 | #include <inttypes.h> |
| 6 | #include <stdarg.h> |
| 7 | #include <stdint.h> |
| 8 | #include <stdio.h> |
| 9 | #include <string.h> |
| 10 | |
| 11 | int main() { |
| 12 | char *p = new char; |
| 13 | char *dest = new char; |
| 14 | const size_t offset = 0x4567890123456789; |
| 15 | |
| 16 | // The output here needs to match the output from the sanitizer runtime, |
| 17 | // which includes 0x and prints hex in lower case. |
| 18 | // |
| 19 | // On Windows, %p omits %0x and prints hex characters in upper case, |
| 20 | // so we use PRIxPTR instead of %p. |
| 21 | fprintf(stderr, format: "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); |
| 25 | |
| 26 | memmove(dest: dest, src: p, n: offset); |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 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 |
| 33 | |