https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79929

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Here's equivlalent C code:

$ cat bug.c
#include <stdlib.h>
#include <string.h>

char * foo(char *c, int len)
{
  char *p, *n;
  n = malloc(len + 5);
  p = c + 5;
  memmove (c, n, p-c);
  if (p < c)
    memset (n + 5, 32, c-p);
  return n;
}
$ gcc -Wall -O -c bug.c
bug.c: In function 'foo':
bug.c:11:5: warning: 'memset': specified size 18446744073709551611 exceeds
maximum object size 9223372036854775807 [-Wstringop-overflow=]
     memset (n + 5, 32, c-p);

I don't think the code is buggy, but the warning is bogus.

Reply via email to