On 21 July 2016 at 11:45, John McCall <[email protected]> wrote:

> > On Jul 21, 2016, at 11:02 AM, Jason Merrill <[email protected]> wrote:
> > P0135 seems to require that we elide the copy when using the result of
> > a function returning by value to initialize a base class subobject,
> > but the ABI doesn't currently require that such a function avoid
> > clobbering tail padding when initializing its return object.
> > Thoughts?
>
> This is not possible in general.  A function returning by value returns a
> complete
> object, i.e. one with its own virtual base subobjects.  We have no choice
> but to
> emit that to a temporary and move out of the non-virtual subobject.
>

That's a great point. At least for classes with virtual bases, we need to
go via a temporary object when initializing a base class with a prvalue.
I'll file a core issue for this.


> The next semantic question is whether it's compatible with NRVO, i.e.
> whether
> there are guarantees about the existence of padding on named local
> variables.
>
> Assuming that it's possible in some definable cases (and I think you could
> easily revise the standard to make it only apply to classes without
> v-bases),
> it seems abstractly reasonable.  Certainly it's generally preferable to
> avoid
> a high-level copy/move + destroy pair than to use a larger store at the end
> of very specific initializers.
>
> As an implementor, I think I'm most worried about how this + NRVO would
> mess up our existing peepholes that assume the existence of tail padding
> on certain complete objects.
>
> John.
> _______________________________________________
> cxx-abi-dev mailing list
> [email protected]
> http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev
>
_______________________________________________
cxx-abi-dev mailing list
[email protected]
http://sourcerytools.com/cgi-bin/mailman/listinfo/cxx-abi-dev

Reply via email to