This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: warn on memset with constant length 0
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Assar <assar at kth dot se>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 03 Dec 2006 15:33:52 -0800
- Subject: Re: PATCH: warn on memset with constant length 0
- References: <85ejrgblwc.fsf@assaris.stacken.kth.se>
On Sun, 2006-12-03 at 18:27 -0500, Assar wrote:
> This is patch to warn when memset is being called with a constant
> length 0. I tested this on i686-pc-linux-gnu.
>
> gcc/ChangeLog:
>
> 2006-12-03 Assar Westerlund <assar@kth.se>
>
> * builtins.c (fold_builtin_memset): Warn about memset with length
> == 0 with -Wextra.
I don't think we should be warning inside builtins.c. Also this really
should gets own option to enable the warning and be part of -Wall and
not -Wextra.
With your patch as it is, it will trigger a warning with:
static inline void f(int *a, int size)
{
memset(a, 0, size);
}
void g(void)
{
f(0, 0);
}
Which is very hard to avoid in some cases (my case is just simplified
case).
Thanks,
Andrew Pinski