1 // RUN: %clangxx_msan -m64 -O0 %s -o %t && %run %t 2 3 // Check that strlen() and similar intercepted functions can be called on shadow 4 // memory. 5 6 #include <assert.h> 7 #include <stdint.h> 8 #include <stdio.h> 9 #include <string.h> 10 11 const char *mem_to_shadow(const char *p) { 12 return (char *)((uintptr_t)p & ~0x400000000000ULL); 13 } 14 15 int main(void) { 16 const char *s = "abcdef"; 17 assert(strlen(s) == 6); 18 assert(strlen(mem_to_shadow(s)) == 0); 19 20 char *t = new char[42]; 21 t[41] = 0; 22 assert(strlen(mem_to_shadow(t)) == 41); 23 return 0; 24 } 25