[cfe-commits] [patch] Warn on memset(p, 0, sizeof(p))

Nico Weber thakis at chromium.org
Mon Jun 13 08:32:55 PDT 2011


On Mon, Jun 13, 2011 at 8:15 AM, Anders Carlsson <andersca at mac.com> wrote:
>
> On Jun 12, 2011, at 10:23 PM, Nico Weber wrote:
>
>> Hi,
>>
>> the attached patch produces this diagnostic
>>
>>  test.cpp:16:17: warning: The sizeof expression in 'memset' has type
>> 'S *', the same type that the first argument has. The sizeof
>> expression should probably have type 'S' instead.
>
> This diagnostic doesn't sound quite right. It's not the sizeof expression that has type 'S *' (the sizeof expression always has type size_t).

Yes, I'm not too happy with the diag wording. I had "The sizeof
argument in…" first, but that made  "…that the first argument has"
ambiguous. Maybe just "Using sizeof pointer type ('S *') instead of
expected type 'S'."? Phrasing suggestions welcome :-)




More information about the cfe-commits mailing list