Mercurial > hg > CbC > CbC_gcc
view 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 |
line wrap: on
line source
/* { dg-do run } */ /* This testcase checks that allocas and VLAs inside loop are correctly unpoisoned. */ #include <assert.h> #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include "sanitizer/asan_interface.h" void *top, *bot; volatile int thirty_two = 32; __attribute__((noinline)) void foo(int len) { char x; top = &x; volatile char array[len]; assert(!((uintptr_t) array & 31L)); alloca(len); for (int i = 0; i < thirty_two; ++i) { char array[i]; bot = array; /* Just to prevent optimization. */ printf("%p\n", bot); assert(!((uintptr_t) bot & 31L)); } } int main(int argc, char **argv) { foo(thirty_two); void *q = __asan_region_is_poisoned(bot, (char *)top - (char *)bot); assert(!q); return 0; }