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 *p; 13 } s1; 14 15 int buf[100]; 16 get()17struct s1 __attribute__((noinline)) get () 18 { 19 struct s1 s; 20 s.p = buf; 21 return s; 22 } 23 rd(struct s1 s,int i)24int __attribute__((noinline)) rd (struct s1 s, int i) 25 { 26 int res = s.p[i]; 27 printf ("%d\n", res); 28 return res; 29 } 30 mpx_test(int argc,const char ** argv)31int mpx_test (int argc, const char **argv) 32 { 33 struct s1 s = get (); 34 35 rd (s, 100); 36 37 return 0; 38 } 39