1 /* PR sanitizer/65280 */
2 /* { dg-do run } */
3 /* { dg-options "-fsanitize=bounds" } */
4 /* Origin: Martin Uecker <uecker@eecs.berkeley.edu> */
5
6 void
foo(volatile int (* a)[3])7 foo (volatile int (*a)[3])
8 {
9 (*a)[3] = 1; // error
10 a[0][0] = 1; // ok
11 a[1][0] = 1; // ok
12 a[1][4] = 1; // error
13 }
14
15 int
main()16 main ()
17 {
18 volatile int a[20];
19 foo ((int (*)[3]) &a);
20 return 0;
21 }
22
23 /* { dg-output "index 3 out of bounds for type 'int \\\[3\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
24 /* { dg-output "\[^\n\r]*index 4 out of bounds for type 'int \\\[3\\\]'" } */
25