This is the mail archive of the
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: <firstname.lastname@example.org>
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.
> 2006-12-03 Assar Westerlund <email@example.com>
> * 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
With your patch as it is, it will trigger a warning with:
static inline void f(int *a, int size)
memset(a, 0, size);
Which is very hard to avoid in some cases (my case is just simplified