On 25 November 2013 21:02, François Dumont wrote:
Hi
Following N3644 discussion thread here is a patch proposal to remove
default zero-initialization of unordered containers iterator. I also took
the time to remove default zero-init of nodes _M_nxt pointer.
2013-11-25 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable_policy.h (_Hash_node_base): Default
default constructor.
(_Node_iterator): Likewise.
(_Node_const_iterator): Likewise.
* include/bits/hashtable.h: Adapt.
Tested under Linux x86_64.
Ok to commit ?
No, I still don't like the idea of leaving data intentionally
uninitialized, so I don't like this part of the patch:
Index: include/bits/hashtable_policy.h
===================================================================
--- include/bits/hashtable_policy.h (revision 205288)
+++ include/bits/hashtable_policy.h (working copy)
@@ -230,7 +230,7 @@
{
_Hash_node_base* _M_nxt;
- _Hash_node_base() noexcept : _M_nxt() { }
+ _Hash_node_base() = default;
_Hash_node_base(_Hash_node_base* __next) noexcept : _M_nxt(__next) { }
};
@@ -306,6 +306,7 @@
__node_type* _M_cur;
+ _Node_iterator_base() = default;
_Node_iterator_base(__node_type* __p) noexcept
: _M_cur(__p) { }
I don't think that will help diagnose errors.
Dereferencing a null pointer will usually cause an immediate failure,
dereferencing uninitialized pointers can have more subtle, harder to
identify problems.