[PATCH] warn on mem calls modifying objects of non-trivial types (PR 80560)
Jason Merrill
jason@redhat.com
Thu Jun 8 01:09:00 GMT 2017
On 06/06/2017 03:24 PM, Martin Sebor wrote:
> + /* Iterate over copy and move assignment overloads. */
> +
> + for (ovl_iterator oi (fns); oi; ++oi)
> + {
> + tree f = *oi;
> +
> + bool accessible = !access || !(TREE_PRIVATE (f) || TREE_PROTECTED (f));
> +
> + /* Skip template assignment operators and deleted functions. */
> + if (TREE_CODE (f) != FUNCTION_DECL || DECL_DELETED_FN (f))
> + continue;
> +
> + if (accessible)
> + *hasassign = true;
> +
> + if (!accessible || !trivial_fn_p (f))
> + all_trivial = false;
> +
> + /* Break early when both properties have been determined. */
> + if (*hasassign && !all_trivial)
> + break;
> + }
This is iterating over all assignment operators, not just copy/move. I
think you want copy_fn_p, here and in has_trivial_copy_p.
It seems redundant to check access here and also check is
is_trivially_xible, which takes access into account. And if we're going
to check access at all, it should consider the access of the current
scope, not just whether the function is private or protected.
Jason
More information about the Gcc-patches
mailing list