[Bug c++/92001] New: missing -Wclass-memaccess with array as first argument to memset
sbergman at redhat dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 5 11:31:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92001
Bug ID: 92001
Summary: missing -Wclass-memaccess with array as first argument
to memset
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sbergman at redhat dot com
CC: msebor at gcc dot gnu.org
Target Milestone: ---
With at least both GCC 9.2.1 and recent trunk towards GCC 10,
#include <cstring>
struct S { S(); };
void f() {
S s[1];
std::memset(s, 0, sizeof s);
}
does not emit a -Wclass-memaccess (but it does when you change s to be of
non-array type).
(See
<https://gerrit.libreoffice.org/plugins/gitiles/core/+/d03041e19215592f21ba1222d3cfa29e1f94260a%5E%21>
"Drop bogus memsets" for a real-life case of such a false negative. There were
about half a dozen similar cases across the LibreOffice code base.)
More information about the Gcc-bugs
mailing list