public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix -Wstring-compare testcase build failure
@ 2020-06-23 14:57 Gary Benson
  2020-06-23 15:57 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Gary Benson @ 2020-06-23 14:57 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-26 13:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 14:57 [PATCH] Fix -Wstring-compare testcase build failure Gary Benson
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

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).