Skip to content
Snippets Groups Projects
Commit 6f2fc42d authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

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.
parent cfaaa8b1
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
// { 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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment