gcc/testsuite/gcc.dg/ubsan/bounds-3.c
raw| 1 | /* PR sanitizer/70875 */ |
| 2 | /* { dg-do run } */ |
| 3 | /* { dg-options "-fsanitize=bounds -fno-sanitize-recover=bounds" } */ |
| 4 | /* { dg-shouldfail "ubsan" } */ |
| 5 | |
| 6 | int |
| 7 | foo (int n, int k) |
| 8 | { |
| 9 | struct S |
| 10 | { |
| 11 | int i[n]; |
| 12 | int value; |
| 13 | } s[2]; |
| 14 | return s[k].value = 0; |
| 15 | } |
| 16 | |
| 17 | int |
| 18 | main () |
| 19 | { |
| 20 | return foo (2, 2); |
| 21 | } |
| 22 | |
| 23 | /* { dg-output "index 2 out of bounds for type 'S \\\[2\\\]'" } */ |