gcc/testsuite/gcc.dg/ubsan/bounds-2.c
raw| 1 | /* PR sanitizer/65280 */ |
| 2 | /* { dg-do run } */ |
| 3 | /* { dg-options "-fsanitize=bounds" } */ |
| 4 | |
| 5 | void |
| 6 | foo (int n, int (*b)[n]) |
| 7 | { |
| 8 | (*b)[n] = 1; |
| 9 | } |
| 10 | |
| 11 | int |
| 12 | main () |
| 13 | { |
| 14 | int a[20]; |
| 15 | foo (3, (int (*)[3]) &a); |
| 16 | } |
| 17 | |
| 18 | /* { dg-output "index 3 out of bounds for type 'int \\\[\\\*\\\]'" } */ |