public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: std::stacktrace tweaks
@ 2023-11-15 11:28 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-11-15 11:28 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested x86_64-linux. Pushed to trunk. Backports to follow.

The new hash.cc test was failing for armv8l-unknown-linux-gnueabihf
according to Linaro CI. This should fix it (but there are still other
failures for std::stacktrace, so I opened PR 112541).

-- >8 --

Fix a typo in a string literal and make the new hash.cc test gracefully
handle missing stacktrace data (see PR 112541).

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::at): Fix class name
	in exception message.
	* testsuite/19_diagnostics/stacktrace/hash.cc: Do not fail if
	current() returns a non-empty stacktrace.
---
 libstdc++-v3/include/std/stacktrace                      | 2 +-
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index 9a0d0b16068..9d5f6396aed 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -425,7 +425,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       at(size_type __n) const
       {
 	if (__n >= size())
-	  __throw_out_of_range("basic_stack_trace::at: bad frame number");
+	  __throw_out_of_range("basic_stacktrace::at: bad frame number");
 	return begin()[__n];
       }
 
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc
index 88831efd687..21705098ff0 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc
@@ -12,9 +12,10 @@ test_hash()
   using Alloc = __gnu_test::uneq_allocator<std::stacktrace_entry>;
   using S = std::basic_stacktrace<Alloc>;
   S s;
+  S cur = S::current();
   std::size_t h = std::hash<S>()(s);
-  std::size_t h2 = std::hash<S>()(S::current());
-  VERIFY( h != h2 );
+  std::size_t h2 = std::hash<S>()(cur);
+  VERIFY( cur.empty() == (h == h2) );
 }
 
 int main()
-- 
2.41.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-15 11:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 11:28 [committed] libstdc++: std::stacktrace tweaks Jonathan Wakely

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