www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics




D.gnu - [Issue 2004] New: no clean way to dynamically loop over va_args

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 users.sf.net
        ReportedBy: fawzi 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.


-- 
Apr 18 2008