diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-11-14 22:02:55 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-11-14 22:32:08 +0000 |
commit | 6f2fc42d9e52e8322e718e0154cd235d00906f99 (patch) | |
tree | e9e3ffa5f5cead3da7f95ff40fd906386271d0e0 | |
parent | cfaaa8b11b8429eed5ec44426fc6a20ad5d53d30 (diff) | |
download | gcc-6f2fc42d9e52e8322e718e0154cd235d00906f99.zip gcc-6f2fc42d9e52e8322e718e0154cd235d00906f99.tar.gz gcc-6f2fc42d9e52e8322e718e0154cd235d00906f99.tar.bz2 |
libstdc++: Fix std::hash<std::stacktrace> [PR112348]
libstdc++-v3/ChangeLog:
PR libstdc++/112348
* include/std/stacktrace (hash<basic_stacktrace<Alloc>>): Fix
type of hash functio nfor entries.
* testsuite/19_diagnostics/stacktrace/hash.cc: New test.
-rw-r--r-- | libstdc++-v3/include/std/stacktrace | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index da0e48d..9a0d0b1 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -797,7 +797,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t operator()(const basic_stacktrace<_Allocator>& __st) const noexcept { - hash<stacktrace_entry::native_handle_type> __h; + hash<stacktrace_entry> __h; size_t __val = _Hash_impl::hash(__st.size()); for (const auto& __f : __st) __val = _Hash_impl::__hash_combine(__h(__f), __val); diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc new file mode 100644 index 0000000..88831ef --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc @@ -0,0 +1,23 @@ +// { dg-options "-lstdc++exp" } +// { dg-do run { target c++23 } } +// { dg-require-effective-target stacktrace } + +#include <stacktrace> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +void +test_hash() +{ + using Alloc = __gnu_test::uneq_allocator<std::stacktrace_entry>; + using S = std::basic_stacktrace<Alloc>; + S s; + std::size_t h = std::hash<S>()(s); + std::size_t h2 = std::hash<S>()(S::current()); + VERIFY( h != h2 ); +} + +int main() +{ + test_hash(); +} |