aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2022-12-29 14:33:03 -0300
committerAlexandre Oliva <oliva@gnu.org>2022-12-29 14:39:47 -0300
commit1b9270852055f2641520fadd63328f997e76d367 (patch)
treec8d37184be71df74bd66aa93ae0461a72be904aa
parent025e3d57995f6a9ede2768cbbe46e4fa49f13b98 (diff)
downloadgcc-1b9270852055f2641520fadd63328f997e76d367.zip
gcc-1b9270852055f2641520fadd63328f997e76d367.tar.gz
gcc-1b9270852055f2641520fadd63328f997e76d367.tar.bz2
hash set: reject attempts to add empty values
Check, after adding a key to a hash set, that the entry does not look empty. for gcc/ChangeLog * hash-set.h (add): Check that the inserted entry does not look empty.
-rw-r--r--gcc/hash-set.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/hash-set.h b/gcc/hash-set.h
index 76fa7f3..a98121a 100644
--- a/gcc/hash-set.h
+++ b/gcc/hash-set.h
@@ -58,7 +58,11 @@ public:
Key *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT);
bool existed = !Traits::is_empty (*e);
if (!existed)
- new (e) Key (k);
+ {
+ new (e) Key (k);
+ // Catch attempts to insert e.g. a NULL pointer.
+ gcc_checking_assert (!Traits::is_empty (*e));
+ }
return existed;
}