26 lines · cpp
1// RUN: %clangxx_asan -O3 %s -o %t && %run %t2 3// Test that no_sanitize_address attribute applies even when the function would4// be normally inlined.5//6// MSVC doesn't apply __declspec(no_sanitize_address) to inlined functions7// (i.e. it contains this bug)8// XFAIL: msvc9 10#include "defines.h"11#include <stdlib.h>12 13ATTRIBUTE_NO_SANITIZE_ADDRESS14int f(int *p) {15 return *p; // BOOOM?? Nope!16}17 18int main(int argc, char **argv) {19 int * volatile x = (int*)malloc(2*sizeof(int) + 2);20 int res = f(x + 2);21 free(x);22 if (res)23 exit(0);24 return 0;25}26