reference to va_list

R

Rich Herrick

Is it defined behavior to use a reference to a va_list to allow calling a
function to extract arguments from the argument list, then upon returning to
the calling function, continue extracting additional arguments. For
example:

int foo2(va_list& list)
{
return int(va_arg(list, int));
}

void foo(int x, ...)
{
va_list list;

va_start(list, x);
int a = foo2(list);
int b = int(va_arg(list, int));
va_end(list);

printf("%d %d %d\n", x, a, b);
}

Ignoring why someone would do this, would calling foo(1, 2, 3) print the
values of the three variables x, a, and b as 1, 2, and 3, respectively?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top