This is the mail archive of the
mailing list for the GCC project.
Re: cannot pass objects of non-POD type
On Thu, Oct 25, 2007 at 11:25:52AM -0400, Daniel Jacobowitz wrote:
> On Wed, Oct 24, 2007 at 03:06:42PM -0700, Joe Buck wrote:
> > But the way that the object is passed in this case, and the stack layout,
> > are completely defined on any platform that obeys the cross-platform API
> > you will find at
> > http://www.codesourcery.com/cxx-abi/
> > and this definition specifies that everything will look exactly the same
> > as if it were a POD with the same members declared in the same order.
> I don't think that's true. I believe the non-POD must be passed in
> memory, but GCC would be permitted to pass the POD in a register if it
> preferred. The layout is defined by the C++ ABI, but not the argument
> passing conventions.
One of the purposes of the C++ ABI is to allow different compilers to
interoperate. The freedom you describe would prevent gcc-compiled
code from behaving correctly with icc-compiled code, for example.
So yes, argument passing conventions are part of the ABI.
Now, in this case there is an "out": a compiler developer can argue
that passing a non-pod to a variadic function isn't defined, so the
ABI doesn't matter.