Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jul 2013 08:10:43 -0700
From:      mdf@FreeBSD.org
To:        David Chisnall <theraven@freebsd.org>
Cc:        "src-committers@freebsd.org" <src-committers@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, Tim Kientzle <kientzle@freebsd.org>, Bruce Evans <brde@optusnet.com.au>, Hans Petter Selasky <hps@bitfrost.no>
Subject:   Re: svn commit: r253636 - head/sys/vm
Message-ID:  <CAMBSHm-hPkiraSBQzRpwdgGdCsKUBA%2BusxYtNsjKujqU4dWU2A@mail.gmail.com>
In-Reply-To: <73FCA347-5EB9-445F-A25C-D06CA137CBEE@FreeBSD.org>
References:  <201307250348.r6P3mbsG049595@svn.freebsd.org> <20130725171038.O841@besplex.bde.org> <51F0DDB0.7080102@bitfrost.no> <73FCA347-5EB9-445F-A25C-D06CA137CBEE@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jul 25, 2013 at 4:43 AM, David Chisnall <theraven@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMBSHm-hPkiraSBQzRpwdgGdCsKUBA%2BusxYtNsjKujqU4dWU2A>