Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/va-arg-trap-1.c

raw
1 /* Undefined behavior from a call to va_arg with a type other than
2 that of the argument passed (in particular, with a type such as
3 "float" that can never be the type of an argument passed through
4 "...") does not appear until after the va_list expression is
5 evaluated. PR 38483. */
6 /* Origin: Joseph Myers <[email protected]> */
7
8 #include <stdarg.h>
9
10 extern void exit (int);
11 extern void abort (void);
12
13 va_list ap;
14 float f;
15
16 va_list *
17 foo (void)
18 {
19 exit (0);
20 return &ap;
21 }
22
23 void
24 bar (int i, ...)
25 {
26 va_start (ap, i);
27 f = va_arg (*foo (), float);
28 va_end (ap);
29 }
30
31 int
32 main (void)
33 {
34 bar (1, 0);
35 abort ();
36 }