From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 564933858402; Mon, 13 Sep 2021 20:15:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 564933858402 From: "drc at linux dot vnet.ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/102316] New: Unexpected stringop-overflow Warnings on POWER CPU Date: Mon, 13 Sep 2021 20:15:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: drc at linux dot vnet.ibm.com 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 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: Mon, 13 Sep 2021 20:15:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102316 Bug ID: 102316 Summary: Unexpected stringop-overflow Warnings on POWER CPU Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: drc at linux dot vnet.ibm.com Target Milestone: --- Building DPDK with gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3) on a POWER9 host and powerpc64le-linux-gnu-gcc (GCC) 11.2.1 20210802 (Advance-Toolchain 15.0-0) [ebcfb7a665c2] on an x86_64 cross-compile host, generates the warni= ng: In function =E2=80=98i40e_flow_parse_fdir_pattern=E2=80=99, inlined from =E2=80=98i40e_flow_parse_fdir_filter=E2=80=99 at ../drivers/net/i40e/i40e_flow.c:3274:8: ../drivers/net/i40e/i40e_flow.c:3052:69: warning: writing 1 byte into a reg= ion of size 0 [-Wstringop-overflow=3D] 3052 | filter->input.flow_ext.flexbytes[j]= =3D | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~^ 3053 | raw_spec->pattern[i]; | ~~~~~~~~~~~~~~~~~~~~ In file included from ../drivers/net/i40e/i40e_flow.c:25: ../drivers/net/i40e/i40e_flow.c: In function =E2=80=98i40e_flow_parse_fdir_= filter=E2=80=99: ../drivers/net/i40e/i40e_ethdev.h:630:17: note: at offset 16 into destinati= on object =E2=80=98flexbytes=E2=80=99 of size 16 630 | uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; | ^~~~~~~~~ See https://bugs.dpdk.org/show_bug.cgi?id=3D743 for additional details on D= PDK build failure.=20=20 Running cvise to reduce the failing code yields the following simplified te= st failure: #include #define LEN 16 struct { char c[LEN] } d; int a =3D LEN; char* b; int p() { for (int i =3D 0; i < a; i++) { d.c[i] =3D b[i]; } return 0; } int main () { int r =3D 0; b =3D malloc(sizeof(char) * (LEN + 1)); r =3D p(); return r; } $ gcc -O3 test.c test.c:6:1: warning: no semicolon at end of struct or union 6 | } d; | ^ test.c: In function 'p': test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 16 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 17 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 18 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 19 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 20 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 21 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 22 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 23 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 24 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 25 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 26 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 27 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 28 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 29 into destination object 'c' of size 16 5 | char c[LEN] | ^ test.c:13:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 13 | d.c[i] =3D b[i]; | ~~~~~~~^~~~~~ test.c:5:8: note: at offset 30 into destination object 'c' of size 16 5 | char c[LEN] | ^ Compiling both the original DPDK and simplified code with -O3 for POWER sys= tems generates the given warnings, but compiling the code with -O2 for POWER sys= tems does not generate the warning. Compiling the simplified code with either -O3 or -O2 for x86_64 systems does not generate a warning.=