summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/mpx/union-arg-1-ubv.c
blob: 6d65e5a73fe28b367ac543dfe2c626f060a8e578 (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"

struct s1
{
  union {
    int i1;
    int i3;
  } v;
  int i2;
  union {
    int *p;
    int p2;
  } u;
} s1;

int rd (struct s1 s)
{
  int res = s.u.p[s.v.i1 + s.i2];
  printf ("%d\n", res);
  return res;
}

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

int mpx_test (int argc, const char **argv)
{
  struct s1 s;
  s.u.p = buf;
  s.v.i1 = 50;
  s.i2 = 50;

  rd (s);

  return 0;
}