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 
12 int
foo2(int i1,int * p1,...)13 foo2 (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 
30 static __attribute__((always_inline)) int
foo1(int * p1,...)31 foo1 (int *p1, ...)
32 {
33   return foo2 (10, p1, __builtin_va_arg_pack ());
34 }
35 
36 int prebuf[100];
37 int buf[100];
38 int buf1[100];
39 int postbuf[100];
40 
mpx_test(int argc,const char ** argv)41 int mpx_test (int argc, const char **argv)
42 {
43   foo1 (buf, buf1, -11);
44   return 0;
45 }
46