aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ubsan/bounds-3.c
blob: 50ad67389f8a82f14e26b3789146ae2146f7ca2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* PR sanitizer/70875 */
/* { dg-do run } */
/* { dg-options "-fsanitize=bounds" } */

int
foo (int n, int k)
{
  struct S
  {
    int i[n];
    int value;
  } s[2];
  return s[k].value = 0;
}

int
main ()
{
  return foo (2, 2);
}

/* { dg-output "index 2 out of bounds for type 'S \\\[2\\\]'" } */