Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/c-c++-common/ubsan/bounds-13.c @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* PR sanitizer/71498 */ /* { dg-do run } */ /* { dg-options "-fsanitize=bounds -Wno-array-bounds" } */ struct S { int a[100]; int b, c; } s; __attribute__((noinline, noclone)) int foo (int x) { return s.a[x]; } __attribute__((noinline, noclone)) int bar (int x) { static int *d = &s.a[99]; asm volatile ("" : : "r" (&d)); return s.a[x]; } int main () { volatile int a = 0; a += foo (100); a += bar (100); return 0; } /* { dg-output "index 100 out of bounds for type 'int \\\[100\\\]'\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output "\[^\n\r]*index 100 out of bounds for type 'int \\\[100\\\]'\[^\n\r]*(\n|\r\n|\r)" } */