1 /* { dg-do run } */
2 /* { dg-shouldfail "bounds violation" } */
3 /* { dg-options "-fcheck-pointer-bounds -mmpx" } */
4 
5 /* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
6 
7 #define SHOULDFAIL
8 
9 #include "mpx-check.h"
10 
11 struct S {
12   int a[10];
13   int b;
14 } S;
15 
16 struct S1 {
17   int a;
18   struct S b[10];
19   int c;
20 } S1;
21 
22 struct S2 {
23   int x;
24   struct S1 a[10];
25   struct S1 b;
26 } S2;
27 
foo(int * p,int i)28 int foo (int *p, int i)
29 {
30   int res = p[i];
31   printf ("%d\n", res);
32   return res;
33 }
34 
35 struct S2 s1;
36 struct S2 *s2 = &s1;
37 
mpx_test(int argc,const char ** argv)38 int mpx_test (int argc, const char **argv)
39 {
40   foo (&(s1.a[argc].b[-1].a[0]), 9);
41 
42   return 0;
43 }
44