From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2C37C38618F6; Wed, 6 Jan 2021 11:14:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C37C38618F6 From: "alexander.grund@tu-dresden.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/98561] New: -Wstringop-overflow triggered when memcpy to single char and writing to differently sized array members Date: Wed, 06 Jan 2021 11:14:00 +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: 10.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alexander.grund@tu-dresden.de 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jan 2021 11:14:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98561 Bug ID: 98561 Summary: -Wstringop-overflow triggered when memcpy to single char and writing to differently sized array members Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: alexander.grund@tu-dresden.de Target Milestone: --- Created attachment 49899 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49899&action=3Dedit Test case to trigger the warning in -O3 This looks very similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D8= 7296 but occurs in GCC 10.0 to 10.2, not before. The test case triggers the bug when compiled with `gcc -O3` but NOT with `g= cc -O2 -ftree-vectorize` as in the above bug. Instead it is `gcc -O2 -fpeel-lo= ops` See reproducer on godbolt: https://godbolt.org/z/Ef1Pne Interesting here is that it does not involve actual OOB access through VLA = or size-0/size-1 hacks and is extremely sensitive. The following changes make = the warning disappear: - changing the array sizes (some combinations only) - hiding the memcpy - using C-Arrays - using a single array - removing either for-loop Also the size of the 2nd array matters for the amount of warnings shown for that line. It seems it is already fixed on trunk but all mentioned issues so far invol= ved a VLA or OOB access so this is not a direct duplicate. Of course the test code is a reduced MWE but you can guess the purpose.=