public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107038] New: [13 Regression] Bogus -Wstringop-overflow= since r13-2789-gb40b3035879cf695
Date: Mon, 26 Sep 2022 08:36:09 +0000	[thread overview]
Message-ID: <bug-107038-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-09-26  8:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26  8:36 marxin at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107038-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).