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

            Bug ID: 100190
           Summary: warning on s390x: writing 1 byte into a region of size
                    0 [-Wstringop-overflow=]
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: f4bug at amsat dot org
  Target Milestone: ---

Using GCC 11.0.0 20210210 (Red Hat 11.0.0-0) on s390x host,
the following code [*] ...:

 22 static inline void *memset(void *s, int c, size_t n)
 23 {
 24     size_t i;
 25     unsigned char *p = s;
 26 
 27     for (i = 0; i < n; i++) {
 28         p[i] = c;
 29     }
 30 
 31     return s;
 32 }

... generates the following warning:

$ make -C pc-bios/s390-ccw
  CCAS    start.o
  CC      main.o
In file included from pc-bios/s390-ccw/main.c:11:
In function ‘memset’,
    inlined from ‘boot_setup’ at pc-bios/s390-ccw/main.c:185:5,
    inlined from ‘main’ at pc-bios/s390-ccw/main.c:288:5:
pc-bios/s390-ccw/libc.h:28:14: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   28 |         p[i] = c;
      |         ~~~~~^~~

[*]
https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/s390-ccw/libc.h#L22

Reply via email to