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

            Bug ID: 86332
           Summary: Incorrect warning with Wstringop-overflow
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: prathamesh3492 at gcc dot gnu.org
  Target Milestone: ---

Hi,
For the following test-case:

void foo(void)
{
  void escape(unsigned char *);

  unsigned char tmp[12];
  unsigned char *p = tmp + 7;
  __builtin_memset (p, 0, 6);
  escape (p);
}

I get warning:
test.c: In function ‘foo’:
test.c:7:3: warning: ‘__builtin_memset’ writing 6 bytes into a region of size 5
overflows the destination [-Wstringop-overflow=]
   __builtin_memset (p, 0, 6);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~

Seems like an "off by one" mistake. Doesn't warn if size of tmp is increased by
1.

Reply via email to