comparison gcc/testsuite/c-c++-common/asan/alloca_loop_unpoisoning.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 1830386684a0
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-do run } */
2
3 /* This testcase checks that allocas and VLAs inside loop are correctly unpoisoned. */
4
5 #include <assert.h>
6 #include <stdint.h>
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include "sanitizer/asan_interface.h"
10
11 void *top, *bot;
12 volatile int thirty_two = 32;
13
14 __attribute__((noinline)) void foo(int len) {
15 char x;
16 top = &x;
17 volatile char array[len];
18 assert(!((uintptr_t) array & 31L));
19 alloca(len);
20 for (int i = 0; i < thirty_two; ++i) {
21 char array[i];
22 bot = array;
23 /* Just to prevent optimization. */
24 printf("%p\n", bot);
25 assert(!((uintptr_t) bot & 31L));
26 }
27 }
28
29 int main(int argc, char **argv) {
30 foo(thirty_two);
31 void *q = __asan_region_is_poisoned(bot, (char *)top - (char *)bot);
32 assert(!q);
33 return 0;
34 }