<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey, Richard et al. Akira and I were talking about the right ABI rule for deciding can-pass-in-registers-ness for structs in the presence of trivial_abi, and I think I like Akira's approach but wanted to get your input.<div class=""><br class=""></div><div class="">The current definition in Itanium is:<div class=""><div class=""><br class=""></div><div class=""> <a name="non-trivial" style="font-family: -webkit-standard;" class=""><i class="">non-trivial for the purposes of calls</i></a></div><dt style="font-family: -webkit-standard;" class=""><a name="non-trivial" class=""></a></dt><dd style="font-family: -webkit-standard;" class=""><a name="non-trivial" class=""><p class="">A type is considered non-trivial for the purposes of calls if:</p><ul class=""><li class="">it has a non-trivial copy constructor, move constructor, or destructor, or</li><li class="">all of its copy and move constructors are deleted.</li></ul></a></dd><div class=""><br class=""></div><div class="">I'd suggest modifying this to:</div></div></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>A type is considered non-trivial for the purposes of calls if:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- if has a copy constructor, move constructor, or destructor which is non-trivial for the purposes of calls, or</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- all of its copy and move constructors are deleted and it does not have the trivial_abi attribute.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>A copy/move constructor is considered trivial for the purposes of calls if:</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>- it is user-provided and</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- the class has the trivial_abi attribute and</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- a defaulted definition of the constructor would be trivial for the purposes of calls; or</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- it is not user-provided and</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- the class has no virtual functions and no virtual base classes, and</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- the constructor used to copy/move each direct base class subobject is trivial for the purposes of calls, and</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- for each non-static data member that is of class type (or array thereof), the constructor selected to copy/move that member is trivial for the purposes of calls.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>A destructor is considered trivial for the purposes of calls if:</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>- it is not user-provided or the class has the trivial_abi attribute, and</div><div class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>- the destructor is not virtual, and</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- all of the direct base classes of its class have destructors that are trivial for the purposes of calls, and</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- for all of the non-static data members of its class that are of class type (or array thereof), each such class is trivial for the purposes of calls.</div></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>These definitions are intended to follow [class.copy.ctor]p11 and [class.dtor]p6 except for the special rules applicable to trivial_abi classes.</div><div class=""><br class=""></div><div class="">I'm not sure about the "defaulted definition" rule for copy/move constructors in trivial_abi classes. The intent is to allow class temploids with trivial_abi that are instantiated to contain non-trivial classes to just silently become non-trivial. I was thinking at first that it would be nice to have a general rule that trivial_abi classes only contain trivial_abi subobjects, but unfortunately that's not consistent with the standard triviality rule in some silly corner cases: a trivially-copyable class can have a non-trivially-copyable subobject if it happens to copy that subobject with a trivial copy constructor. I couldn't think of a better way of capturing this than the "defaulted definition" rule. I considered using the actual initializers used by the constructor, but that would introduce a lot of new complexity: suddenly we'd be asking about triviality for an arbitrary constructor, and copy/move elision make the question somewhat ambiguous anyway.</div><div class=""><br class=""></div><div class="">I'm also not sure about the right rules about virtual methods. Should we allow polymorphic classes to be made trivial by application of the attribute?</div><div class=""><br class=""></div><div class="">John.</div></body></html>