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 int buf[100]; 11 12 int __attribute((nothrow)) rd(int * p,int i)13rd (int *p, int i) 14 { 15 int res = p[i]; 16 printf ("%d\n", res); 17 return res; 18 } 19 set_p(int * & ref)20void set_p (int *&ref) 21 { 22 ref = buf; 23 } 24 mpx_test(int argc,const char ** argv)25int mpx_test (int argc, const char **argv) 26 { 27 int *p; 28 29 set_p (p); 30 rd (p, -1); 31 32 return 0; 33 } 34