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