Bug 2004 – no clean way to dynamically loop over va_args

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2008-04-18T09:19:00Z
Last change time
2015-06-09T05:14:44Z
Assigned to
ibuclaw
Creator
fawzi
Blocks
670, 1968

Comments

Comment #0 by fawzi — 2008-04-18T09:19:57Z
due to the structure of va_list there is no easy way to loop over unknown arguments. Skipping them based on their size is not easy even using tricks (a template generating a fake structure of the requested size), because also the alignment must be known and it is difficult to gather from typeinfo. One possibility would be to re-implement The cleanest thing would be either to either implement a function void *dyn_va_arg(TypeInfo,va_list) that returns a pointer to the type, and skips it. Barring alignment issues of the arguments passed in the registers, this should be easy for the compiler to implement. If alignment issues are a problem then I think that a void*dyn_va_arg_tmp(TypeInfo,va_list,out bool) that gives a temporary pointer and says if the pointer is temporary could be considered, but only as last resort, if at all possible a clean re-implementation of va_arg for D should be considered. Such a function would make boxer, tangos Layout and similar things possible in a clean way.
Comment #1 by ibuclaw — 2011-01-31T09:39:09Z
As per, bug1066, closing.