From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix -Wstring-compare testcase build failure
Date: Tue, 23 Jun 2020 15:57:08 +0100 [thread overview]
Message-ID: <1592924228-13346-1-git-send-email-gbenson@redhat.com> (raw)
Hi all,
Clang fails to compile the file gdb/testsuite/gdb.cp/try_catch.cc
with the following error:
warning: result of comparison against a string literal is
unspecified (use strncmp instead) [-Wstring-compare]
This patch replaces the string literal with a pointer, to avoid
the error.
Is it ok to commit?
Cheers,
Gary
--
gdb/testsuite/ChangeLog:
* gdb.cp/try_catch.cc: Replace string literal with a
pointer to avoid build failure with -Wstring-compare.
---
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.cp/try_catch.cc | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.cp/try_catch.cc b/gdb/testsuite/gdb.cp/try_catch.cc
index 4c4add2..b0c01ba 100644
--- a/gdb/testsuite/gdb.cp/try_catch.cc
+++ b/gdb/testsuite/gdb.cp/try_catch.cc
@@ -122,14 +122,15 @@ int main()
// 3 use standard library
using namespace std;
+ const char *throwme = "gdb.1";
try
{
if (j < 100)
- throw invalid_argument("gdb.1"); // marker 3-throw
+ throw invalid_argument(throwme); // marker 3-throw
}
catch (exception& obj)
{
- if (obj.what() != "gdb.1") // marker 3-catch
+ if (obj.what() != throwme) // marker 3-catch
test &= false;
}
return 0;
--
1.8.3.1
next reply other threads:[~2020-06-23 14:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 14:57 Gary Benson [this message]
2020-06-23 15:57 ` Pedro Alves
2020-06-26 13:05 ` [PATCH v2] " Gary Benson
2020-06-26 13:19 ` Pedro Alves
2020-06-26 13:54 ` Gary Benson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1592924228-13346-1-git-send-email-gbenson@redhat.com \
--to=gbenson@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).