Add the following test case to HashSet.cpp in WTF tests: TEST(WTF, HashSetFindZero) { HashSet<uint64_t> testSet; // Initial capacity is null. ASSERT_EQ(0, testSet.capacity()); testSet.add(static_cast<uint64_t>(123)); testSet.add(static_cast<uint64_t>(456)); ASSERT_TRUE(testSet.find(static_cast<uint64_t>(0)) == testSet.end()); } You'll hit an assertion in template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> template<typename HashTranslator, typename T> void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::checkKey(const T& key) { if (!HashFunctions::safeToCompareToEmptyOrDeleted) return; ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key)); This results in HashSet::find returning a bogus iterator and HashSet::remove deleting an unrelated item, resulting in a really bad consistent state where size can be a bogus value like -1.
Created attachment 185869 [details] Fixes the bug
Comment on attachment 185869 [details] Fixes the bug Sam says we shouldn't do this.
I'll fix the internal code instead.
This is by design, but you can just change the HashTrait to support the value 0.