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

struct S
{
  unsigned long a[1];
  int l;
};

static inline unsigned long
fn (const struct S *s, int i)
{
  return s->a[i] / i;
}

int
main ()
{
  struct S s;
  fn (&s, 1);
}

/* { dg-output "index 1 out of bounds for type 'long unsigned int \\\[1\\\]'" } */