This is the mail archive of the
mailing list for the GCC project.
Re: [wwwdocs] gcc-4.8/porting_to.html
It still references memcpy in -Wsizeof-pointer-memaccess section. Let me
To fix, properly pass the size of cleared memory as the last argument:
either dereference the pointer argument to sizeof when clearing *one
pointed-to element*, or in addition to that multiply sizeof(*p) by the
number of elements to clear in the pointed-to array (which may not be
known at the point of memset call without additional code changes).
I suppose a good chunk of problematic code hitting this warning would be doing
void foo(int a)
memset(a, 0, sizeof(a));
... in which case dereferencing a in sizeof is probably the wrong thing to do.