public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111696] New: [11/12/13/14 Regression] Spurious -Wstringop-overflow
@ 2023-10-04 18:03 stilor at att dot net
  2023-10-04 22:50 ` [Bug middle-end/111696] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: stilor at att dot net @ 2023-10-04 18:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111696
           Summary: [11/12/13/14 Regression] Spurious -Wstringop-overflow
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stilor at att dot net
  Target Milestone: ---

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

The attached testcase started producing a warning beginning with commit
8d57bdadd2d9c2e5c95515ca7a583d7b407b55c4 when compiled with `-O3` (or `-O2
-ftree-slp-vectorize`). Starting with commit
2b8453c401b699ed93c085d0413ab4b5030bcdb8, vectorization is also enabled at
`-O2` and the testcase starting failing at `-O2` as well. The warning can be
reproduced at current HEAD (96557ee6a0a234821af865800d22621efa6e7390) as well.

Failure message:

$ /usr/gcc-test/bin/gcc -c -O3 -Wall -Werror stringop-overflow-bug-gcc.c 
stringop-overflow-bug-gcc.c: In function ‘update’:
stringop-overflow-bug-gcc.c:25:3: error: writing 24 bytes into a region of size
16 [-Werror=stringop-overflow=]
   25 |   memcpy(&last->s, &cur.s, sizeof(struct nested));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stringop-overflow-bug-gcc.c:10:17: note: destination object ‘a’ of size 16
   10 |   unsigned long a[2];
      |                 ^
cc1: all warnings being treated as errors
$ /usr/gcc-test/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/gcc-test/bin/gcc
COLLECT_LTO_WRAPPER=/usr/gcc-test/libexec/gcc/x86_64-pc-linux-gnu/11.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages=c --prefix=/usr/gcc-test
--disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.0.1 20210303 (experimental) (GCC) 


The message is bogus:
- the "note" points to a member inside a structure and references that member's
size while memcpy has the whole structure as a destination.
- commenting out any of the first two statements in the update() function
removes the warning even though it has no effect on the addresses passed to
memcpy().

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

* [Bug middle-end/111696] [11/12/13/14 Regression] Spurious -Wstringop-overflow
  2023-10-04 18:03 [Bug middle-end/111696] New: [11/12/13/14 Regression] Spurious -Wstringop-overflow stilor at att dot net
@ 2023-10-04 22:50 ` pinskia at gcc dot gnu.org
  2023-10-04 22:55 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-04 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The vectorizer has not much to do with the warning issue except for the IR
change into FRE.

Before fre5:
  _11 = &last_14(D)->s;
  memcpy (_11, &cur.s, 24);


After:
  vectp.7_19 = &accum_13(D)->sD.4831.aD.4827[0];
...
  vectp.10_9 = &last_14(D)->sD.4831.aD.4827[0];
...
  # .MEM_26 = VDEF <.MEM_12(D)>
  MEM <vector(2) long unsigned intD.17> [(long unsigned intD.17 *)vectp.7_19] =
vect__5.13_24;
  # .MEM_17 = VDEF <.MEM_26>
  MEM <unsigned charD.31[24]> [(charD.11 * {ref-all})vectp.10_9] = MEM
<unsigned charD.31[24]> [(charD.11 * {ref-all})&curD.4832];

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

* [Bug middle-end/111696] [11/12/13/14 Regression] Spurious -Wstringop-overflow
  2023-10-04 18:03 [Bug middle-end/111696] New: [11/12/13/14 Regression] Spurious -Wstringop-overflow stilor at att dot net
  2023-10-04 22:50 ` [Bug middle-end/111696] " pinskia at gcc dot gnu.org
@ 2023-10-04 22:55 ` pinskia at gcc dot gnu.org
  2023-10-05  7:38 ` rguenth at gcc dot gnu.org
  2024-03-07 21:06 ` law at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-04 22:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I remember seeing this similar issue before where PRE/FRE/VN decides the two
addresses are the same (they are) but since waccess does not realize other
passes will use the restricted address still and still warn.

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

* [Bug middle-end/111696] [11/12/13/14 Regression] Spurious -Wstringop-overflow
  2023-10-04 18:03 [Bug middle-end/111696] New: [11/12/13/14 Regression] Spurious -Wstringop-overflow stilor at att dot net
  2023-10-04 22:50 ` [Bug middle-end/111696] " pinskia at gcc dot gnu.org
  2023-10-04 22:55 ` pinskia at gcc dot gnu.org
@ 2023-10-05  7:38 ` rguenth at gcc dot gnu.org
  2024-03-07 21:06 ` law at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-05  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.5
             Blocks|                            |88443


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings

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

* [Bug middle-end/111696] [11/12/13/14 Regression] Spurious -Wstringop-overflow
  2023-10-04 18:03 [Bug middle-end/111696] New: [11/12/13/14 Regression] Spurious -Wstringop-overflow stilor at att dot net
                   ` (2 preceding siblings ...)
  2023-10-05  7:38 ` rguenth at gcc dot gnu.org
@ 2024-03-07 21:06 ` law at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
           Priority|P3                          |P2

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

end of thread, other threads:[~2024-03-07 21:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-04 18:03 [Bug middle-end/111696] New: [11/12/13/14 Regression] Spurious -Wstringop-overflow stilor at att dot net
2023-10-04 22:50 ` [Bug middle-end/111696] " pinskia at gcc dot gnu.org
2023-10-04 22:55 ` pinskia at gcc dot gnu.org
2023-10-05  7:38 ` rguenth at gcc dot gnu.org
2024-03-07 21:06 ` law 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).