summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/mpx/return-pointer-1-lbv.c
blob: 9a209b8d3044c96f7ba6ab0a87e8ddfc72d01a8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */


#define SHOULDFAIL

#include "mpx-check.h"

int *_buf1[100];
int _buf2[100];

int **get_buf1 ()
{
  return _buf1;
}

int *get_buf2 ()
{
  return _buf2;
}

void wr (int i, int **buf1, int *buf2)
{
  buf1[i] = buf2;
}

int rd (int i, int j, int **buf)
{
  int res = buf[i][j];
  printf ("%d\n", res);
  return res;
}

int mpx_test (int argc, const char **argv)
{
  int **buf1 = get_buf1 ();
  int *buf2 = get_buf2 ();
  wr(10, buf1, buf2);
  rd(10, -1, buf1);

  return 0;
}