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 i;
17 int res;
18
19 va_start(argp, p1);
20 i = va_arg(argp, int);
21
22 res = p1[i + i1];
23 printf("%d\n", res);
24
25 return res;
26 }
27
28 static __attribute__((always_inline)) int
foo1(int * p1,...)29 foo1 (int *p1, ...)
30 {
31 return foo2 (10, p1, __builtin_va_arg_pack ());
32 }
33
34 int prebuf[100];
35 int buf[100];
36 int postbuf[100];
37
mpx_test(int argc,const char ** argv)38 int mpx_test (int argc, const char **argv)
39 {
40 foo1 (buf, 90);
41 return 0;
42 }
43