From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 10E893858C52; Wed, 4 Oct 2023 18:03:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10E893858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696442610; bh=83a7y1o5V7eIaXdbgGYSFVz8MeYgIZ5WsITogF5xelQ=; h=From:To:Subject:Date:From; b=RsJDZCo1vs5pY82H/pFy3Cy2t9FDBCC9AuQitlatUFqdYJgZC8Wy1WMM79cfcsL/8 yLp366nxoYngY0w4PA+12ii7DPRxNSa5GZ7v4BgroV41gpMKejtIZ8zGRdaunD1Woy nP7hebpsKODlSVBk/yeg8oRzFOjlInWlEWICkZoE= From: "stilor at att dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/111696] New: [11/12/13/14 Regression] Spurious -Wstringop-overflow Date: Wed, 04 Oct 2023 18:03:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: stilor at att dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111696 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=3D56052&action=3Dedit 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 we= ll. Failure message: $ /usr/gcc-test/bin/gcc -c -O3 -Wall -Werror stringop-overflow-bug-gcc.c=20 stringop-overflow-bug-gcc.c: In function =E2=80=98update=E2=80=99: stringop-overflow-bug-gcc.c:25:3: error: writing 24 bytes into a region of = size 16 [-Werror=3Dstringop-overflow=3D] 25 | memcpy(&last->s, &cur.s, sizeof(struct nested)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ stringop-overflow-bug-gcc.c:10:17: note: destination object =E2=80=98a=E2= =80=99 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=3D/usr/gcc-test/bin/gcc COLLECT_LTO_WRAPPER=3D/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=3Dc --prefix=3D/usr/gc= c-test --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.0.1 20210303 (experimental) (GCC)=20 The message is bogus: - the "note" points to a member inside a structure and references that memb= er'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().=