-Wclass-memaccess doesn't trigger for access to arrays of objects whose type it's designed to trigger for. It looks to me like a simple oversight in maybe_warn_class_memaccess. Attached is a trivial patch to correct it tested on x86_64-linux.
Martin
PR c++/92001 - missing -Wclass-memaccess with array as first argument to memset gcc/cp/ChangeLog: PR c++/92001 * call.c (maybe_warn_class_memaccess): Handle arrays. gcc/testsuite/ChangeLog: PR c++/92001 * g++.dg/Wclass-memaccess-5.C: New test. Index: gcc/cp/call.c =================================================================== --- gcc/cp/call.c (revision 276657) +++ gcc/cp/call.c (working copy) @@ -8910,7 +8910,9 @@ maybe_warn_class_memaccess (location_t loc, tree f unsigned srcidx = !dstidx; tree dest = (*args)[dstidx]; - if (!TREE_TYPE (dest) || !INDIRECT_TYPE_P (TREE_TYPE (dest))) + if (!TREE_TYPE (dest) + || (TREE_CODE (TREE_TYPE (dest)) != ARRAY_TYPE + && !INDIRECT_TYPE_P (TREE_TYPE (dest)))) return; tree srctype = NULL_TREE; Index: gcc/testsuite/g++.dg/Wclass-memaccess-5.C =================================================================== --- gcc/testsuite/g++.dg/Wclass-memaccess-5.C (nonexistent) +++ gcc/testsuite/g++.dg/Wclass-memaccess-5.C (working copy) @@ -0,0 +1,18 @@ +/* PR c++/92001 - missing -Wclass-memaccess with array as first argument + to memset + { dg-do compile } + { dg-options "-Wall" } */ + +extern "C" void* memset (void*, int, __SIZE_TYPE__); + +struct S { S (); }; + +void test_array_access (S *p, S (*pa)[2], S (&r)[3]) +{ + S a[1]; + memset (a, 0, sizeof a); // { dg-warning "-Wclass-memaccess" } + + memset (*pa, 0, sizeof *pa); // { dg-warning "-Wclass-memaccess" } + + memset (r, 0, sizeof r); // { dg-warning "-Wclass-memaccess" } +}