summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/mpx/return-struct-3-ubv.c
blob: 83b81da83905cdd983340a0236563211d1953276 (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
/* { dg-do run } */
/* { dg-shouldfail "bounds violation" } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */


#define SHOULDFAIL

#include "mpx-check.h"

struct s1
{
  int *p1;
  int *p;
} s1;

int buf[100];
int buf1[10];

struct s1 __attribute__((noinline)) get ()
{
  struct s1 s;
  s.p = buf;
  s.p1 = buf1;
  return s;
}

int __attribute__((noinline)) rd (struct s1 s, int i)
{
  int res = s.p[i];
  printf ("%d\n", res);
  return res;
}

int mpx_test (int argc, const char **argv)
{
  struct s1 s = get ();

  rd (s, 100);

  return 0;
}