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