This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: warn on memset with constant length 0


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]