Debian Codegraph @

gcc/testsuite/c-c++-common/ubsan/pr81604.c

raw
1 /* PR sanitizer/81604 */
2 /* { dg-do run } */
3 /* { dg-options "-fsanitize=bounds,signed-integer-overflow" } */
4
5 long a[10];
6
7 __attribute__((noinline, noclone)) long *
8 foo (int i)
9 {
10 return &a[i];
11 }
12
13 __attribute__((noinline, noclone)) long
14 bar (long x, long y)
15 {
16 return x * y;
17 }
18
19 int
20 main ()
21 {
22 volatile int i = -1;
23 volatile long l = __LONG_MAX__;
24 long *volatile p;
25 p = foo (i);
26 l = bar (l, l);
27 return 0;
28 }
29
30 /* { dg-output "index -1 out of bounds for type 'long int \\\[10\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
31 /* { dg-output "\[^\n\r]*signed integer overflow: \[0-9]+ \\* \[0-9]+ cannot be represented in type 'long int'" } */