summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/typesafe.h2
-rw-r--r--tests/lib/test_typelist.h5
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/typesafe.h b/lib/typesafe.h
index 66612be167..8eb59c33b7 100644
--- a/lib/typesafe.h
+++ b/lib/typesafe.h
@@ -948,6 +948,8 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
macro_pure bool prefix ## _member(const struct prefix##_head *h, \
const type *item) \
{ \
+ if (!h->hh.tabshift) \
+ return NULL; \
uint32_t hval = item->field.hi.hashval, hbits = HASH_KEY(h->hh, hval); \
const struct thash_item *hitem = h->hh.entries[hbits]; \
while (hitem && hitem->hashval < hval) \
diff --git a/tests/lib/test_typelist.h b/tests/lib/test_typelist.h
index 91528139b5..80c4005437 100644
--- a/tests/lib/test_typelist.h
+++ b/tests/lib/test_typelist.h
@@ -171,6 +171,11 @@ static void concat(test_, TYPE)(void)
ts_hash("init", "df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119");
+#if !IS_ATOMIC(REALTYPE)
+ assert(!list_member(&head, &itm[0]));
+ assert(!list_member(&head, &itm[1]));
+#endif
+
#if IS_SORTED(REALTYPE)
prng = prng_new(0);
k = 0;