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