title: How to use va_list object in a nested way, especially on gcc x64 compiler
body: <p>Please look through my small C/C++ program.</p>
  
  <pre><code>// va_nest.c
  #include &lt;stdarg.h&gt;
  #include &lt;stdio.h&gt;
  
  void nest2(const char *fmt, ...)
  {
      va_list args2, args_dig;
      int *pi, i;
  
      va_start(args2, fmt);
  
      args_dig = va_arg(args2, va_list); 
          // !!! try to fetch the nested va_list object.
      pi = va_arg(args_dig, int*);
      i = va_arg(args_dig, int);
  
      printf("Inner: @%p , %d\n", pi, i);
  
      va_end(args2);
  }
  
  void nest1(const char *fmt, ...)
  {
      va_list args1;
      va_start(args1, fmt);
  
      nest2(fmt, args1);
  
      va_end(args1);
  }
  
  int main()
  {
      int var = 11;
      printf("Outer: @%p , %d\n", &amp;var, var);
      nest1("abc", &amp;var, var);
      return 0;
  }
  </code></pre>
  
  <p>On openSUSE 13.1 x86, it outputs just want I expect(no matter using gcc or g++),</p>
  
  <pre><code>Outer: @0xbfa18d8c , 11
  Inner: @0xbfa18d8c , 11
  </code></pre>
  
  <p>However, it FAILS with x86_64 compiler on openSUSE 13.1 x64 machine.</p>
  
  <p>If I compile it with <code>gcc</code>, it compiles ok, but output is unexpected.</p>
  
  <pre><code>$ gcc -o vac va_nest.c
  
  $ ./vac
  Outer: @0x7fffb20f766c , 11
  Inner: @0x1b01000000636261 , 4209411
  </code></pre>
  
  <p>If I compile it with <code>g++</code>, it even fails to compile.</p>
  
  <pre><code>$ g++ -o vacpp va_nest.c
  va_nest.c: In function ‘void nest2(const char*, ...)’:
  va_nest.c:12:11: error: invalid array assignment
    args_dig = va_arg(args2, va_list);
             ^
  </code></pre>
  
  <p>gcc and g++ version is 4.8.1</p>
  
  <p>Can anybody help me with that? I hope to achieve the same result on x64 as in Linux x86 compiler.</p>