Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion when removing poly component #1206

Open
hfn92 opened this issue Jan 2, 2025 · 0 comments
Open

assertion when removing poly component #1206

hfn92 opened this issue Jan 2, 2025 · 0 comments

Comments

@hfn92
Copy link

hfn92 commented Jan 2, 2025

In version 3.14.0

struct TestConcept : entt::type_list<void()>
{
  template<typename Base>
  struct type : Base
  {
    void test()
    {
      entt::poly_call<0>(*this);
    }
  };

  template<typename Type>
  using impl = entt::value_list<&Type::test>;
};

using TestPoly = entt::poly<TestConcept>;

TEST(entt, poly_remove)
{
  entt::registry reg;
  auto e = reg.create();
  reg.emplace<TestPoly>(e, TestPoly{});
  reg.remove<TestPoly>(e);
}

triggers: entt::basic_any<Len, <anonymous> >& entt::basic_any<Len, <anonymous> >::operator=(entt::basic_any<Len, <anonymous> >&&) [with long unsigned int Len = 16; long unsigned int Align = 8]: Assertion ((this != &other) && ("Self move assignment"))' failed.`

entt/core/any.hpp|262| entt::basic_any<Len, <anonymous> >& entt::basic_any<Len, <anonymous> >::operator=(entt::basic_any<Len, <anonymous> >&&) [with long unsigned int Len = 16; long unsigned int Align = 8]: Assertion `((this != &other) && ("Self move assignment"))' failed.
|| Stack trace (most recent call last):
/usr/src/debug/glibc/glibc/nptl/pthread_kill.c|44| __pthread_kill_implementation [0x7f119e0a53f4]
../sysdeps/posix/raise.c|26| raise [0x7f119e04c11f]
/usr/src/debug/glibc/glibc/stdlib/abort.c|79| abort [0x7f119e0334c2]
/usr/src/debug/glibc/glibc/assert/assert.c|94| __assert_fail_base [0x7f119e0333de]
/usr/src/debug/glibc/glibc/assert/assert.c|103| __assert_fail [0x7f119e044176]
/entt/core/any.hpp|262| operator= [0x63c98bb6bc23]
||         259:    * @return This any object.
||         260:    */
||         261:   basic_any &operator=(basic_any &&other) noexcept {
||       > 262:     ENTT_ASSERT(this != &other, "Self move assignment");
||         263: 
||         264:     reset();
/entt/poly/poly.hpp|193| operator= [0x63c98bb8bed5]
||         190:  * @tparam Align Optional alignment requirement.
||         191:  */
||         192: template<typename Concept, std::size_t Len, std::size_t Align>
||       > 193: class basic_poly: private Concept::template type<poly_base<basic_poly<Concept, Len, Align>>> {
||         194:     friend struct poly_base<basic_poly>;
||         195: 
||         196: public:
/usr/include/c++/14.2.1/bits/move.h|178| __exchange<entt::basic_poly<Behaviours::BehaviourConcept, 16, 8>, entt::basic_poly<Behaviours::BehaviourConcept, 16, 8> > [0x63c98be4b241]
||         175:     __exchange(_Tp& __obj, _Up&& __new_val)
||         176:     {
||         177:       _Tp __old_val = std::move(__obj);
||       > 178:       __obj = std::forward<_Up>(__new_val);
||         179:       return __old_val;
||         180:     }
/usr/include/c++/14.2.1/utility|110| exchange<entt::basic_poly<Behaviours::BehaviourConcept, 16, 8>, entt::basic_poly<Behaviours::BehaviourConcept, 16, 8> > [0x63c98be44f7b]
||         107:     exchange(_Tp& __obj, _Up&& __new_val)
||         108:     noexcept(__and_<is_nothrow_move_constructible<_Tp>,
||         109:                is_nothrow_assignable<_Tp&, _Up>>::value)
||       > 110:     { return std::__exchange(__obj, std::forward<_Up>(__new_val)); }
||         111: #endif
||         112: 
||         113: #ifdef  __cpp_lib_as_const // C++ >= 17
/entt/entity/storage.hpp|345| pop [0x63c98be45086]
||         342:             } else {
||         343:                 auto &other = element_at(base_type::size() - 1u);
||         344:                 // destroying on exit allows reentrant destructors
||       > 345:                 [[maybe_unused]] auto unused = std::exchange(elem, std::move(other));
||         346:                 alloc_traits::destroy(allocator, std::addressof(other));
||         347:                 base_type::swap_and_pop(first);
||         348:             }
/entt/entity/mixin.hpp|95| pop [0x63c98be44c10]
||          92:                 const auto entt = *first;
||          93:                 destruction.publish(reg, entt);
||          94:                 const auto it = underlying_type::find(entt);
||       >  95:                 underlying_type::pop(it, it + 1u);
||          96:             }
||          97:         }
||          98:     }
/entt/entity/sparse_set.hpp|816| erase [0x63c98bd52f06]
||         813:      */
||         814:     void erase(const entity_type entt) {
||         815:         const auto it = to_iterator(entt);
||       > 816:         pop(it, it + 1u);
||         817:     }
||         818: 
||         819:     /**
/entt/entity/sparse_set.hpp|845| remove [0x63c98bd52e86]
||         842:      * @return True if the entity is actually removed, false otherwise.
||         843:      */
||         844:     bool remove(const entity_type entt) {
||       > 845:         return contains(entt) && (erase(entt), true);
||         846:     }
||         847: 
||         848:     /**
/entt/entity/registry.hpp|716| remove<entt::basic_poly<Behaviours::BehaviourConcept, 16, 8> > [0x63c98be243ff]
||         713:      */
||         714:     template<typename Type, typename... Other>
||         715:     size_type remove(const entity_type entt) {
||       > 716:         return (assure<Type>().remove(entt) + ... + assure<Other>().remove(entt));
||         717:     }
||         718: 
||         719:     /**
/entt/entity/handle.hpp|257| remove<entt::basic_poly<Behaviours::BehaviourConcept, 16, 8> > [0x63c98be1fcdf]
||         254:     // NOLINTNEXTLINE(modernize-use-nodiscard)
||         255:     size_type remove() const {
||         256:         static_assert(sizeof...(Scope) == 0 || (type_list_contains_v<type_list<Scope...>, Type> && ...), "Invalid type");
||       > 257:         return owner_or_assert().template remove<Type...>(entt);
||         258:     }
||         259: 
||         260:     /**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant