This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct


On Sat, Feb 20, 2016 at 10:48 PM, Richard Smith <richard@metafoo.co.uk> wrote:
> On 20 Feb 2016 10:01 p.m., "H.J. Lu" <hjl.tools@gmail.com> wrote:
>>
>> On Sat, Feb 20, 2016 at 9:47 PM, Richard Smith <richard@metafoo.co.uk>
>> wrote:
>> > On 20 Feb 2016 6:54 p.m., "H.J. Lu" <hjl.tools@gmail.com> wrote:
>> >>
>> >> On Sat, Feb 20, 2016 at 4:57 PM, Matthijs van Duin
>> >> <matthijsvanduin@gmail.com> wrote:
>> >> > On 20 February 2016 at 23:35, H.J. Lu <hjl.tools@gmail.com> wrote:
>> >> >> Can a compiler tell if a copy constructor or destructor is trivial
>> >> >> from the class declaration without function body?
>> >> >
>> >> > Yes, the mere presence of the declaration suffices to render it
>> >> > non-trivial (unless explicitly declared "= default" like I did with
>> >> > the default constructor, in which case there's no function body).
>> >>
>> >> How about this?
>> >>
>> >> An empty type is a type where it and all of its subobjects
>> >> (recursively)
>> >> are of class, structure, union, or array type.  An empty type may only
>> >> have static member functions, default  constructor, default copy
>> >> constructor, default copy assignment operator or default destructor.
>> >
>> > No, that's the wrong rule still. Please leave the C++ rule here to the
>> > C++
>> > ABI rather than trying to reinvent it. Whether a type is empty is
>> > completely
>> > orthogonal to whether it must be passed through memory for C++ ABI /
>> > semantics reasons.
>>
>> What is the correct wording?  The last one:
>>
>> An empty type is a type where it and all of its subobjects (recursively)
>> are of class, structure, union, or array type.
>>
>> doesn't cover "trivially-copyable".
>
> That's correct. Whether a type is trivially copyable is unrelated to whether
> it is empty.

Let get me what you were suggesting.  The x86 psABIs define the empty
type as

An empty type is a type where it and all of its subobjects (recursively)
are of class, structure, union, or array type.  No memory slot nor register
should be used to pass or return an object of empty type.

Footnote: Array of empty type can only passed by reference in C and C++.

As for what other C++ types, which aren't empty type as defined by x86
psABIs, can be passed and returned without memory slot nor register
belong to C++ ABI.

Am I correct?

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]