1 /* { dg-do run } */ 2 /* { dg-shouldfail "bounds violation" } */ 3 /* { dg-options "-fcheck-pointer-bounds -mmpx" } */ 4 5 6 #define SHOULDFAIL 7 8 #include "mpx-check.h" 9 10 struct s1 11 { 12 int i1; 13 int i2; 14 int *p; 15 int i3; 16 int i4; 17 } s1; 18 19 int buf[100]; 20 get()21struct s1 __attribute__((noinline)) get () 22 { 23 struct s1 s; 24 s.p = buf; 25 return s; 26 } 27 rd(struct s1 s,int i)28int __attribute__((noinline)) rd (struct s1 s, int i) 29 { 30 int res = s.p[i]; 31 printf ("%d\n", res); 32 return res; 33 } 34 mpx_test(int argc,const char ** argv)35int mpx_test (int argc, const char **argv) 36 { 37 struct s1 s = get (); 38 39 rd (s, 100); 40 41 return 0; 42 } 43