1/* { dg-do run } */
2/* { dg-shouldfail "bounds violation" } */
3/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
4
5/* { dg-additional-options "-Wno-attributes" } */
6
7#define SHOULDFAIL
8
9#include "mpx-check.h"
10#include <stdarg.h>
11
12int
13foo2 (int i1, int *p1, ...)
14{
15  va_list argp;
16  int *p;
17  int i;
18  int res;
19
20  va_start(argp, p1);
21  p = va_arg(argp, int *);
22  i = va_arg(argp, int);
23
24  res = p[i + i1];
25  printf("%d\n", res);
26
27  return res;
28}
29
30static __attribute__((always_inline)) int
31foo1 (int *p1, ...)
32{
33  return foo2 (10, p1, __va_arg_pack ());
34}
35
36int prebuf[100];
37int buf[100];
38int buf1[100];
39int postbuf[100];
40
41int mpx_test (int argc, const char **argv)
42{
43  foo1 (buf, buf1, 90);
44  return 0;
45}
46