diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index ff42863de..49dba31b1 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -244,6 +244,7 @@ class basic_registry { static_assert(std::is_same_v>, "Non-decayed types not allowed"); if constexpr(std::is_same_v) { + ENTT_ASSERT(id == type_hash::value(), "User entity storage not allowed"); return entities; } else { auto &cpool = pools[id]; @@ -272,6 +273,7 @@ class basic_registry { static_assert(std::is_same_v>, "Non-decayed types not allowed"); if constexpr(std::is_same_v) { + ENTT_ASSERT(id == type_hash::value(), "User entity storage not allowed"); return &entities; } else { if(const auto it = pools.find(id); it != pools.cend()) { diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index d1c1f28aa..7d26b12c1 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -525,6 +525,9 @@ ENTT_DEBUG_TEST(RegistryDeathTest, Storage) { ASSERT_DEATH(registry.storage("other"_hs), ""); ASSERT_DEATH(std::as_const(registry).storage("other"_hs), ""); + + ASSERT_DEATH(registry.storage("other"_hs), ""); + ASSERT_DEATH(std::as_const(registry).storage("other"_hs), ""); } TEST(Registry, Identifiers) {