From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA02E3858404; Tue, 9 Nov 2021 19:35:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA02E3858404 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/101919] Inconsistent -Wstringop-overread warning with -flto Date: Tue, 09 Nov 2021 19:35:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: diagnostic, lto X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW 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: blocked cc bug_status everconfirmed cf_known_to_fail cf_reconfirmed_on 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: Tue, 09 Nov 2021 19:35:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101919 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |97048 CC| |msebor at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Known to fail| |11.2.0, 12.0 Last reconfirmed| |2021-11-09 --- Comment #1 from Martin Sebor --- Confirmed with 11 and top of trunk. I think there are two problems: 1) -Wstringop-overread is a C/C++ only option that shouldn't be issued for FOR= TRAN code, and 2) the code the warning triggers for in the IL does look invalid: [local count: 536870913]: _8 =3D _gfortran_string_len_trim (100, &c); _9 =3D (integer(kind=3D4)) _8; _10 =3D (integer(kind=3D8)) _9; if (_10 <=3D 111) goto ; [50.00%] else goto ; [50.00%] [local count: 268435456]: __builtin_memmove (&c, &c[13]{lb: 1 sz: 1}, 100); <<< warning here If I'm reading the FORTRAN code right, c is an array of 100 characters. The memmove call copies 100 characters from &c[13], which would make the copy o= ut of bounds. (1) is a known problem. We don't have a way to describe language-specific options at the LTO level. They're either LTO options ore they're not, so we either enable them for all languages or for none. (2) is an optimizer problem. It should not be emitting clearly invalid cod= e. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97048 [Bug 97048] [meta-bug] bogus/missing -Wstringop-overread warnings=