On Thu, Jul 25, 2013 at 4:43 AM, David Chisnall <thera...@freebsd.org>wrote:

> However(), memset is to be preferred in this idiom because the compiler
> provides better diagnostics in the case of error:
>
> bzero.c:9:22: warning: 'memset' call operates on objects of type 'struct
> foo'
>       while the size is based on a different type 'struct foo *'
>       [-Wsizeof-pointer-memaccess]
>         memset(f, 0, sizeof(f));
>                ~            ^
> bzero.c:9:22: note: did you mean to dereference the argument to 'sizeof'
> (and
>       multiply it by the number of elements)?
>         memset(f, 0, sizeof(f));
>                             ^
>
> The same line with bzero(f, sizeof(f)) generates no error.
>

Isn't that a compiler bug?  memset(p, 0, n) is the same as bzero(p, n).
 Why would the compiler warn on one and not the other?

Does clang have a similar bias for memcpy versus bcopy?

Thanks,
matthew
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to