summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/ubsan/undefined-2.c
blob: 9f764f80091fc8ad19a9141f16d79ca7ea5da12f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* { dg-do run } */
/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=signed-integer-overflow" } */
/* { dg-additional-options "-std=gnu11" { target c } } */
/* { dg-additional-options "-std=c++11" { target c++ } } */

volatile int w, z;

__attribute__ ((noinline, noclone)) int
foo (int x, int y)
{
  z++;
  return x << y;
}

int
main ()
{
  w = foo (0, -__INT_MAX__);
  return 0;
}

/* { dg-output "shift exponent -\[^\n\r]* is negative" } */