public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-10304] libstdc++: Value-initialize objects held by EBO helpers [PR 100863] Date: Fri, 26 Nov 2021 16:34:40 +0000 (GMT) [thread overview] Message-ID: <20211126163440.557FA3857C5F@sourceware.org> (raw) https://gcc.gnu.org/g:cc56c03a7a7f034f98a835dcb7047ad3d2ace6bd commit r10-10304-gcc56c03a7a7f034f98a835dcb7047ad3d2ace6bd 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 | 5 +++-- .../testsuite/23_containers/unordered_map/allocator/default_init.cc | 1 - .../testsuite/23_containers/unordered_set/allocator/default_init.cc | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index d34fc39a973..63958cc1d9c 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1109,7 +1109,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) @@ -1135,7 +1135,7 @@ namespace __detail _Tp& _M_get() { return _M_tp; } private: - _Tp _M_tp; + _Tp _M_tp{}; }; /** @@ -1789,6 +1789,7 @@ namespace __detail protected: _Hashtable_base() = default; + _Hashtable_base(const _ExtractKey& __ex, const _H1& __h1, const _H2& __h2, const _Hash& __hash, const _Equal& __eq) : __hash_code_base(__ex, __h1, __h2, __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 473a5f1ce47..3da42453152 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 37110dd6eb0..1f2f3516859 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>
reply other threads:[~2021-11-26 16:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211126163440.557FA3857C5F@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).