deleted functions, implicit move constructors, and the ABI

Jason Merrill jason at redhat.com
Tue Jun 22 15:22:32 UTC 2010


I thought I remembered Lawrence sending mail to the list about deleted 
functions a while back, but I don't see it now.  But in N3053 he notes 
that ABIs may want to treat deleted functions as trivial in some situations.

There are two places in the ABI that deal with triviality:

1) Array new cookies.  If the destructor is deleted, we won't ever call 
it, so it doesn't require a cookie.

2) Parameter/return value passing.  Currently if the copy constructor or 
destructor is non-trivial, we pass and return by invisible reference. 
We might as well treat a deleted dtor as trivial in this case as well, 
though it's not a very interesting case.

We definitely don't want to change the C++98-compatible cases (implicit 
trivial, implicit non-trivial, user-provided).  But what if the copy 
constructor is deleted, or there is no copy constructor because it's 
suppressed by a user-declared move constructor?

It seems natural to change "a non-trivial copy constructor or 
destructor" to "a non-trivial, non-deleted copy constructor, move 
constructor or destructor".

OTOH, that would make changing a no-copy class's copy constructor or 
destructor from private and undefined to deleted an ABI change, so 
perhaps we should treat deleted functions as non-trivial for this 
purpose (and array new cookies).  I am ambivalent on this point.

But we definitely need to do something about classes with a move 
constructor and no copy constructor.  I think we want to add "move 
constructor" to the list as above, for consistency with the definition 
of "trivially copyable".

Thoughts?

Jason



More information about the cxx-abi-dev mailing list