This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/50500 (DR 1082, implicitly declared copy in class with move)
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Benjamin Kosnik <bkoz at redhat dot com>
- Date: Sat, 29 Oct 2011 23:07:06 +0200
- Subject: Re: C++ PATCH for c++/50500 (DR 1082, implicitly declared copy in class with move)
- References: <4E9DB91F.4050500@redhat.com>
> DR 1082 changed the rules for implicitly declared copy constructors and
> assignment operators in the presence of move ctor/op= such that if
> either move operation is present, instead of being suppressed the copy
> operations will still be declared, but as deleted.
We have detected a side effect of this change by means of -fdump-ada-spec:
implicit copy assignment operators are now generated in simple cases where
they were not previously generated, for example:
template<class T, class U> class Generic_Array
{
Generic_Array();
void mf(T t, U u);
};
template class Generic_Array<char, int>; // explicit instantiation
This is because, during the call to lazily_declare_fn on sfk_copy_constructor,
the new code:
/* [class.copy]/8 If the class definition declares a move constructor or
move assignment operator, the implicitly declared copy constructor is
defined as deleted.... */
if ((sfk == sfk_copy_assignment
|| sfk == sfk_copy_constructor)
&& (type_has_user_declared_move_constructor (type)
|| type_has_user_declared_move_assign (type)))
DECL_DELETED_FN (fn) = true;
is invoked, and type_has_user_declared_move_assign has the side effect of
causing lazily_declare_fn to be called on sfk_copy_assignment through the call
to lookup_fnfields_slot:
bool
type_has_user_declared_move_assign (tree t)
{
tree fns;
if (CLASSTYPE_LAZY_MOVE_ASSIGN (t))
return false;
for (fns = lookup_fnfields_slot (t, ansi_assopname (NOP_EXPR));
fns; fns = OVL_NEXT (fns))
{
tree fn = OVL_CURRENT (fns);
if (move_fn_p (fn) && !DECL_ARTIFICIAL (fn))
return true;
}
return false;
}
Is that expected?
--
Eric Botcazou