public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107038] New: [13 Regression] Bogus -Wstringop-overflow= since r13-2789-gb40b3035879cf695
@ 2022-09-26  8:36 marxin at gcc dot gnu.org
  2022-09-26  9:30 ` [Bug tree-optimization/107038] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-26  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107038
           Summary: [13 Regression] Bogus -Wstringop-overflow= since
                    r13-2789-gb40b3035879cf695
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: amacleod at redhat dot com, msebor at gcc dot gnu.org
  Target Milestone: ---

Created attachment 53627
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53627&action=edit
Original unreduced test-case

Reduced from elfutils:

$ cat core-file.c
#include <unistd.h>
struct ar_hdr {
  char ar_mode[8];
  char ar_size[10];
};

int r;

struct Elf {
  int fildes;
} pread_retry(int fd, void *buf, size_t len, off_t offset) {
  ssize_t recvd;
  r = pread(fd, buf + recvd, len - recvd, offset);
}

void elf_begin_rand() {
  struct Elf *parent;
  struct ar_hdr h;
  pread_retry(parent->fildes, h.ar_size, sizeof(h.ar_size), 0);
}

$ gcc core-file.c -c -O2 -Werror=stringop-overflow -D_FORTIFY_SOURCE=3
In file included from /usr/include/features.h:490,
                 from /usr/include/unistd.h:25,
                 from core-file.c:1:
In function ‘pread’,
    inlined from ‘pread_retry’ at core-file.c:13:7,
    inlined from ‘elf_begin_rand’ at core-file.c:19:3:
/usr/include/bits/unistd.h:74:10: error: ‘__pread_alias’ writing 18 or more
bytes into a region of size 10 overflows the destination
[-Werror=stringop-overflow=]
   74 |   return __glibc_fortify (pread, __nbytes, sizeof (char),
      |          ^~~~~~~~~~~~~~~
core-file.c: In function ‘elf_begin_rand’:
core-file.c:4:8: note: destination object ‘ar_size’ of size 10
    4 |   char ar_size[10];
      |        ^~~~~~~
/usr/include/bits/unistd.h:50:16: note: in a call to function ‘__pread_alias’
declared with attribute ‘access (write_only, 2, 3)’
   50 | extern ssize_t __REDIRECT (__pread_alias,
      |                ^~~~~~~~~~
cc1: some warnings being treated as errors

I'm attaching also original unreduced test-case.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-07-27  9:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26  8:36 [Bug tree-optimization/107038] New: [13 Regression] Bogus -Wstringop-overflow= since r13-2789-gb40b3035879cf695 marxin at gcc dot gnu.org
2022-09-26  9:30 ` [Bug tree-optimization/107038] " rguenth at gcc dot gnu.org
2022-09-26 14:29 ` siddhesh at gcc dot gnu.org
2022-09-26 14:31 ` marxin at gcc dot gnu.org
2022-09-26 16:16 ` msebor at gcc dot gnu.org
2022-09-26 18:32 ` siddhesh at gcc dot gnu.org
2022-09-26 18:41 ` siddhesh at gcc dot gnu.org
2022-09-26 19:16 ` marxin at gcc dot gnu.org
2022-10-07 19:06 ` [Bug tree-optimization/107038] Bogus -Wstringop-overflow in dead code siddhesh at gcc dot gnu.org
2022-10-07 19:08 ` siddhesh at gcc dot gnu.org
2022-10-07 19:09 ` siddhesh at gcc dot gnu.org
2023-04-26  6:56 ` rguenth at gcc dot gnu.org
2023-07-27  9:23 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).