sparsepp
sparsepp copied to clipboard
SEGV after moving hash_map
Linux/Darwin gcc/clang MWE
spp::sparse_hash_map<uint64_t, uint64_t> map0;
map0.emplace(0, 0);
auto map1 = std::move(map0);
//map0 = spp::sparse_hash_map<uint64_t, uint64_t>{}; // uncomment this to pass the test
auto found = map0.find(0); // segfaults here
CHECK(found == end(map0));
What is the intended behavior here? A moved-from object is generally assumed to be in an undefined state. Presumably, this means that it can still be validly-destructed, but you can't do much else with it. I guess, the most robust behavior would be for the moved-from map to be empty ; is that what you would expect? Any thoughts @greg7mdp?
@rob-p yes indeed the moved-from object should be in a consistent state, so this is a bug. I'll look into it when I have some time. In the meanwhile maybe phmap is a good alternative.