sparsehash/sparsehash-c11

Undefined behavior in dense_hashtable move constructor

Closed this issue · 0 comments

GCC 12 reports (correctly) in release builds that the move constructor of dense_hash_map (and presumably dense_hash_set) reads uninitialized variables when key_type is an integral or other type whose default value is undefined.

It happens when the move constructor calls swap() which swaps key_info. The key_info struct contains two fields which are normally assigned by set_empty_key() and set_deleted_key(). The uninitialized variables delkey and empty_key end up being copied from this to the moved-from object.