www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2320] New: ABI spec has contradictory information

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2320

           Summary: ABI spec has contradictory information
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: spec
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: tomas famolsen.dk


The D ABI spec on how variadic functions are implemented has the two
contradictory sentences: "The caller is expected to clean the stack. _argptr is
not passed, it is computed by the callee."

Only one of these can be fulfilled. I suggest changing the ABI to mandate
passing the variadic arguments as a pointer to the arguments (in the caller's
stack frame).

This is also much more portable, making D easier to implement in a compiler for
more than one architecture. For example, x86-64 does not use the stack for
variadic arguments ...


-- 
Aug 29 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2320





------- Comment #1 from tomas famolsen.dk  2008-08-29 10:27 -------
November last year I wrote a proposal for allowing to pass on variadic
arguments without the ugly wrapper functions (a very common feature request).
Fixing this bug, as I suggest, will allow this to be implemented.

See the NG thread for more details:
http://www.digitalmars.com/d/archives/digitalmars/D/How_to_delegate_varargs_62119.html


-- 
Aug 29 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2320


fawzi gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fawzi gmx.ch




------- Comment #2 from fawzi gmx.ch  2008-08-29 12:08 -------
Such an approach would also (as noted) make the "passing on" of vararg
possible.
I would prefer if one finds a syntax to "switch off" the automatic generation
of _argptr and arguments, and is able to pass them directly to the D function.

This cleanly solves most issues with vararg that come form portability (and gdc
has many of them), has a small cost, but it should be ok. D (unlike C) does not
allow one to call a function without having a declaration that shows that it is
a vararg function, so one can safely disregard all C issues.

An issue that is still open is alignement: TypeInfo does not have that
information and without it unpacking (and thus packing) the data cannot keep it
into account.
I think that it is wrong to have pointers to the structure that do not respect
its alignment requirements.

A last note: vararg is not made irrelevant by Variadic templates, because is
some occasions one wants to avoid the extra code usage (but this is no show
stopper, at least to me), and because sometime one wants to have a method in a
class and using Variadic templates makes it final.


-- 
Aug 29 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2320


tomas famolsen.dk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #3 from tomas famolsen.dk  2008-10-23 06:18 -------
I just realized I misread the docs. It's not contradictory, just not portable
:/
I read it as "The _callee_ is expected to clean the stack..."

I wish the ABI would change to not use C-style varargs to implement this, this
would make a lot of things possible with variadic that can't be done now.

But in any case this specific bug report is invalid :(


-- 
Oct 23 2008