scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

0214-va_copy.c (279B)


      1 #include <stdarg.h>
      2 
      3 int
      4 f(int c, ...)
      5 {
      6 	va_list va1, va2;
      7 
      8 	va_start(va1, c);
      9 	c += va_arg(va1, int);
     10 	va_copy(va2, va1);
     11 	c += va_arg(va2, int);
     12 	c += va_arg(va1, int);
     13 
     14 	va_end(va1);
     15 	va_end(va2);
     16 
     17 	return c;
     18 }
     19 
     20 int
     21 main()
     22 {
     23 	if (f(0, 1, 2, 7) != 5)
     24 		return 1;
     25 	return 0;
     26 }