varargs and covariant returns
Martin von Loewis
loewis at informatik.hu-berlin.de
Tue Aug 10 11:07:51 UTC 1999
> Daveed had talked about being able to use simple fixup thunks for covariant
> returns, just overriding the incoming return address; but now that I think
> about it, I don't know where we would store the real return address so that
> the thunk could find it again.
Exactly. Since there already was the decision not to return a list of
pointers from a covariant method, the only alternative to real thunks
is code duplication (as done in Sun Workshop 5).
With real thunks, you have to copy the argument list. That is not
possible for a varargs list, so here is my proposal for varargs in
C++:
In the place of the ellipsis, a pointer to the first argument is
passed. In case of a thunk for covariant returns, this pointer can be
copied to the destination function. The variable arguments are put on
the stack as they normally would.
With that, the issue is in which cases to use such a calling
convention:
1) only for vararg calls to virtual methods, or
2) only for vararg calls to functions with C++ linkage, or
3) for all vararg calls. That would probably require a change to the C
ABI
Option 1) could be further restricted to methods returning a pointer
or reference to class type.
Regards,
Martin
More information about the cxx-abi-dev
mailing list