[Issue 2004] New: no clean way to dynamically loop over va_args

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 18 07:19:58 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2004

           Summary: no clean way to dynamically loop over va_args
           Product: DGCC aka GDC
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn at users.sf.net
        ReportedBy: fawzi at gmx.ch
OtherBugsDependingO 670,1968
             nThis:


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.


-- 



More information about the D.gnu mailing list