[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
From:       Richard Smith via cfe-commits <cfe-commits () lists ! llvm ! org>
Date:       2016-02-21 6:48:46
Message-ID: CAOfiQqnQtJLNoa_aXtxeOiPQAJ6F7Grut14S9OyoUdvdAnUZuQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

[Attachment #5 (text/html)]

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


[Attachment #6 (text/plain)]

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic