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