From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2161) id 3C3D1385625F; Wed, 4 May 2022 14:19:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C3D1385625F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Mark Wielaard To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: Workaround stringop-overread warning in debuginfod-support.c on s390x X-Act-Checkin: binutils-gdb X-Git-Author: Mark Wielaard X-Git-Refname: refs/heads/master X-Git-Oldrev: 5890af36e5112bcbb8d7555e63570f68466e6944 X-Git-Newrev: 716e54731f30bc60b2fc52996ebe4fc087420b2e Message-Id: <20220504141910.3C3D1385625F@sourceware.org> Date: Wed, 4 May 2022 14:19:10 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2022 14:19:10 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D716e54731f30= bc60b2fc52996ebe4fc087420b2e commit 716e54731f30bc60b2fc52996ebe4fc087420b2e Author: Mark Wielaard Date: Tue May 3 23:17:31 2022 +0000 gdb: Workaround stringop-overread warning in debuginfod-support.c on s3= 90x =20 For some reason g++ 11.2.1 on s390x produces a spurious warning for stringop-overread in debuginfod_is_enabled for url_view. Add a new DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD macro to suppress this warning. =20 include/ChangeLog: =20 * diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD): New macro. =20 gdb/ChangeLog: =20 * debuginfod-support.c (debuginfod_is_enabled): Use DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD on s390x. Diff: --- gdb/debuginfod-support.c | 11 +++++++++++ include/diagnostics.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index dffcd782e7d..f2a31ea1952 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -17,6 +17,7 @@ along with this program. If not, see . = */ =20 #include "defs.h" +#include "diagnostics.h" #include #include "gdbsupport/scoped_fd.h" #include "debuginfod-support.h" @@ -192,7 +193,17 @@ debuginfod_is_enabled () if (off =3D=3D gdb::string_view::npos) break; url_view =3D url_view.substr (off); +#if defined (__s390x__) + /* g++ 11.2.1 on s390x seems convinced url_view might be of + SIZE_MAX length. And so complains because the length of + an array can only be PTRDIFF_MAX. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD +#endif off =3D url_view.find_first_of (' '); +#if defined (__s390x__) + DIAGNOSTIC_POP +#endif gdb_printf (_(" <%ps>\n"), styled_string (file_name_style.style (), diff --git a/include/diagnostics.h b/include/diagnostics.h index f10d066150a..8bf5a3c3d9b 100644 --- a/include/diagnostics.h +++ b/include/diagnostics.h @@ -76,6 +76,9 @@ # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \ DIAGNOSTIC_IGNORE ("-Wstringop-truncation") =20 +# define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD \ + DIAGNOSTIC_IGNORE ("-Wstringop-overread") + # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \ DIAGNOSTIC_IGNORE ("-Wformat-nonliteral") =20 @@ -108,6 +111,10 @@ # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION #endif =20 +#ifndef DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD +# define DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD +#endif + #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL #endif