Safe to get address of va_list function parameter?

J

James Kuyper

D said:
Seems sketchy. Varargs are implemented via macros. va_arg() has
destructive semantics, and it might only working in the current stack
frame. What is the address of a register? See `man stdarg`, especially
the section on va_copy().

Since varargs only deal with POD types, why not just copy the value?

Note: D Herring was responding to a cross-post to comp.lang.lisp, with
follow-ups redirected to clc.
 
T

Tim Rentsch

Kaz Kylheku said:
[snip]

The values of va_list objects can in fact be propagated by assignment a
function argument passing. The caveat is that if you extract from the list with
va_arg, then only that copy passed to va_arg is correctly updated (which is why
va_arg has to be a macro). Any other copies become indeterminate, because they
have not been updated with the new value.

They may have been updated, and they may not have been; it's
because they only /may/ have been updated that the original
object is indeterminate. The reason for this rule is to allow
the va_list type to be an array type, which actually would result
in the original object being used (and updated) rather than
having its value copied (and not updated).
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top