1 | // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t |
2 | // RUN: %clangxx_msan -O3 -g %s -o %t && %run %t |
3 | |
4 | #include <assert.h> |
5 | #include <stdlib.h> |
6 | #include <string.h> |
7 | #include <stdio.h> |
8 | #include <sanitizer/msan_interface.h> |
9 | |
10 | int main(void) { |
11 | char *p = (char *)alloca(16); |
12 | assert(0 == __msan_test_shadow(p, 16)); |
13 | assert(0 == __msan_test_shadow(p + 15, 1)); |
14 | |
15 | memset(s: p, c: 0, n: 16); |
16 | assert(-1 == __msan_test_shadow(p, 16)); |
17 | |
18 | volatile int x = 0; |
19 | char * volatile q = (char *)alloca(42 * x); |
20 | assert(-1 == __msan_test_shadow(p, 16)); |
21 | |
22 | int r[x]; |
23 | int *volatile r2 = r; |
24 | assert(-1 == __msan_test_shadow(p, 16)); |
25 | } |
26 | |