From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5CFCF38708B5; Thu, 14 Jan 2021 15:12:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CFCF38708B5 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/95276] [10/11 Regression] Amusing stringpop-overflow message building libgfortran Date: Thu, 14 Jan 2021 15:12:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: 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: Thu, 14 Jan 2021 15:12:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95276 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #13 from Martin Sebor --- The latest trunk outputs the same warning with a better note (the offset is correct). As discussed in comment #7 the warning for the small test case is correct: the loop overflows the small buffer. It iterates at least three times, writing two bytes into the four byte destination in each iteration, = for a total of six bytes. I don't see a bug here so I'm resolving it as invali= d.=20 If the test case below isn't representative of the fortran code please subm= it one that is. $ cat pr95276.c && gcc -O2 -S -Wall pr95276.c char a[4]; void f (char *s, int n) { if (n <=3D 2) return; char *d =3D a; for (int i =3D 0; i < n; i++) { extern volatile unsigned char h, l; *d++ =3D s[h]; *d++ =3D s[l]; } *d =3D '\0'; } pr95276.c: In function =E2=80=98f=E2=80=99: pr95276.c:18:6: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=3D] 18 | *d =3D '\0'; | ~~~^~~~~~ pr95276.c:1:6: note: at offset 6 into destination object =E2=80=98a=E2=80= =99 of size 4 1 | char a[4]; | ^=