aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/ubsan/bounds-3.c
blob: fcf71a3bf8a0965b437f5f2d3cf01db7952d7ff5 (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 compile } */
/* { dg-options "-fsanitize=bounds -Wall -Wextra" } */

/* Do not generate invalid diagnostics.  */

extern const int a[10];
extern int bar (int);
void
foo (int i, int j)
{
  bar (a[i] >> j);
  bar ((unsigned long) a[i] >> j);
  bar ((short int) (unsigned long) a[i] >> j);
  bar (j >> a[i]);
  bar (j >> (unsigned long) a[i]);
  bar (j >> (short int) (unsigned long) a[i]);
  bar (a[i] / j);
  bar ((unsigned long) a[i] / j);
  bar ((short int) (unsigned long) a[i] / j);
  bar (j / a[i]);
  bar (j / (unsigned long) a[i]);
  bar (j / (short int) (unsigned long) a[i]);
}