diff options
author | Martin Sebor <msebor@redhat.com> | 2019-12-09 20:54:11 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-12-09 13:54:11 -0700 |
commit | 49070d06708a8d8ae3af767f89ac40c4c12dca7b (patch) | |
tree | a61f278fe57a15598a51858bffa5b56ac45978df /gcc/hash-table.h | |
parent | ca6932ad0ccbbbe3c788cd71595d9a25b8ae0d20 (diff) | |
download | gcc-49070d06708a8d8ae3af767f89ac40c4c12dca7b.zip gcc-49070d06708a8d8ae3af767f89ac40c4c12dca7b.tar.gz gcc-49070d06708a8d8ae3af767f89ac40c4c12dca7b.tar.bz2 |
PR middle-end/92761 - hash_table::expand invokes assignment on invalid objects
PR middle-end/92761 - hash_table::expand invokes assignment on invalid objects
PR middle-end/92762 - hash_table::empty_slow invokes assignment on invalid objects
gcc/ChangeLog:
PR middle-end/92761
PR middle-end/92762
* hash-map-tests.c (test_map_of_type_with_ctor_and_dtor): Tighten
up tests.
* hash-table.h (hash_table::expand): Use placement new to copy
construct objects in uninitialized storage.
(hash_table::empty_slow): Avoid invoking copy assignment on
uninitialized objects.
From-SVN: r279139
Diffstat (limited to 'gcc/hash-table.h')
-rw-r--r-- | gcc/hash-table.h | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/gcc/hash-table.h b/gcc/hash-table.h index ba5d64f..26bac62 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -818,8 +818,7 @@ hash_table<Descriptor, Lazy, Allocator>::expand () if (!is_empty (x) && !is_deleted (x)) { value_type *q = find_empty_slot_for_expand (Descriptor::hash (x)); - - *q = x; + new ((void*) q) value_type (x); } p++; @@ -869,14 +868,8 @@ hash_table<Descriptor, Lazy, Allocator>::empty_slow () m_size_prime_index = nindex; } else - { -#ifndef BROKEN_VALUE_INITIALIZATION - for ( ; size; ++entries, --size) - *entries = value_type (); -#else - memset (entries, 0, size * sizeof (value_type)); -#endif - } + memset ((void *) entries, 0, size * sizeof (value_type)); + m_n_deleted = 0; m_n_elements = 0; } |