public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9139] libstdc++: Value-initialize objects held by EBO helpers [PR 100863]
@ 2021-10-12 19:41 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-10-12 19:41 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:573c2ffd3cacde5c54605eb0d8b312d22594f7fa
commit r11-9139-g573c2ffd3cacde5c54605eb0d8b312d22594f7fa
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jun 2 12:34:48 2021 +0100
libstdc++: Value-initialize objects held by EBO helpers [PR 100863]
The allocator, hash function and equality function should all be
value-initialized by the default constructor of an unordered container.
Do it in the EBO helper, so we don't have to get it right in multiple
places.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/100863
PR libstdc++/65816
* include/bits/hashtable_policy.h (_Hashtable_ebo_helper):
Value-initialize subobject.
* testsuite/23_containers/unordered_map/allocator/default_init.cc:
Remove XFAIL.
* testsuite/23_containers/unordered_set/allocator/default_init.cc:
Remove XFAIL.
(cherry picked from commit f8f0193b5b83f6e85d65015e79c803295baf5166)
Diff:
---
libstdc++-v3/include/bits/hashtable_policy.h | 6 ++++--
.../testsuite/23_containers/unordered_map/allocator/default_init.cc | 1 -
.../testsuite/23_containers/unordered_set/allocator/default_init.cc | 1 -
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index ad8a4ec5f07..9d7b7ad29ca 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -1123,7 +1123,7 @@ namespace __detail
struct _Hashtable_ebo_helper<_Nm, _Tp, true>
: private _Tp
{
- _Hashtable_ebo_helper() = default;
+ _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
template<typename _OtherTp>
_Hashtable_ebo_helper(_OtherTp&& __tp)
@@ -1149,7 +1149,7 @@ namespace __detail
_Tp& _M_get() { return _M_tp; }
private:
- _Tp _M_tp;
+ _Tp _M_tp{};
};
/**
@@ -1207,6 +1207,7 @@ namespace __detail
// We need the default constructor for the local iterators and _Hashtable
// default constructor.
_Hash_code_base() = default;
+
_Hash_code_base(const _Hash& __hash) : __ebo_hash(__hash) { }
__hash_code
@@ -1600,6 +1601,7 @@ namespace __detail
protected:
_Hashtable_base() = default;
+
_Hashtable_base(const _Hash& __hash, const _Equal& __eq)
: __hash_code_base(__hash), _EqualEBO(__eq)
{ }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc
index bbfd683d433..12f1163951e 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++11 } }
// { dg-options "-O0" }
-// { dg-xfail-run-if "PR c++/65816" { *-*-* } }
#include <unordered_map>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc
index 6ee32d45ceb..1ea6603024e 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc
@@ -17,7 +17,6 @@
// { dg-do run { target c++11 } }
// { dg-options "-O0" }
-// { dg-xfail-run-if "PR c++/65816" { *-*-* } }
#include <unordered_set>
#include <testsuite_hooks.h>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-12 19:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 19:41 [gcc r11-9139] libstdc++: Value-initialize objects held by EBO helpers [PR 100863] 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).