]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: std::stacktrace tweaks
authorJonathan Wakely <jwakely@redhat.com>
Wed, 15 Nov 2023 09:17:49 +0000 (09:17 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 15 Nov 2023 11:30:44 +0000 (11:30 +0000)
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.

(cherry picked from commit cbd0fe22a5ced9751d2450dc4fd6fe3525c2fc02)

libstdc++-v3/include/std/stacktrace
libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc

index 967029354339aa5c3dbf768ef91825665f9a69d3..e4ca2d6bfa999df19d41c62a62aa883d2fd254e2 100644 (file)
@@ -496,7 +496,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];
       }
 
index cf18476f2a7f53d48e8a2e95ca30a4ba21f1122f..a2f61e49981b6aa8b0d8cbf42eb06622b1d902da 100644 (file)
@@ -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()