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 union { 13 int i1; 14 int i3; 15 } v; 16 int i2; 17 union { 18 int *p; 19 int p2; 20 } u; 21 } s1; 22 rd(struct s1 s)23int rd (struct s1 s) 24 { 25 int res = s.u.p[s.v.i1 + s.i2]; 26 printf ("%d\n", res); 27 return res; 28 } 29 30 int buf[100]; 31 int buf1[10]; 32 mpx_test(int argc,const char ** argv)33int mpx_test (int argc, const char **argv) 34 { 35 struct s1 s; 36 s.u.p = buf; 37 s.v.i1 = 50; 38 s.i2 = -51; 39 40 rd (s); 41 42 return 0; 43 } 44