https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117046
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
else if (!trivial
&& !VOID_TYPE_P (srctype)
&& !is_byte_access_type (srctype)
&& !same_type_ignoring_top_level_qualifiers_p (desttype,
srctype))
When you use bytes.data() the src type is unsigned char which is a "byte access
type" and so g++ doesn't warn. When you use &bytes it's not copying from
unsigned char.
So the warning really is telling you that Foo is non-trivial (which is
correct), but the warning is suppressed when copying from unsigned char*
I think this is working as designed.