[Bug c++/81327] [8 Regression] cast to void* does not suppress -Wclass-memaccess
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 4 20:22:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81327
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
I don't consider this a regression. The warnings are justified and it wasn't a
design goal to let casts suppress them. I agree it would be useful for
compatibility with Clang (that's why I raised the bug), but making it possible
is an enhancement. Until it's implemented, the warnings can be selectively
suppressed via GCC's diagnostic pragmas:
void g (struct S *s)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
__builtin_memset ((void*)s, 0, sizeof *s);
#pragma GCC diagnostic pop
}
More information about the Gcc-bugs
mailing list