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 *_buf1[100];
11 int _buf2[100];
12
get_buf1()13 int **get_buf1 ()
14 {
15 return _buf1;
16 }
17
get_buf2()18 int *get_buf2 ()
19 {
20 return _buf2;
21 }
22
wr(int i,int ** buf1,int * buf2)23 void wr (int i, int **buf1, int *buf2)
24 {
25 buf1[i] = buf2;
26 }
27
rd(int i,int j,int ** buf)28 int rd (int i, int j, int **buf)
29 {
30 int res = buf[i][j];
31 printf ("%d\n", res);
32 return res;
33 }
34
mpx_test(int argc,const char ** argv)35 int mpx_test (int argc, const char **argv)
36 {
37 int **buf1 = get_buf1 ();
38 int *buf2 = get_buf2 ();
39 wr(10, buf1, buf2);
40 rd(10, -1, buf1);
41
42 return 0;
43 }
44