SanderMertens / flecs

A fast entity component system (ECS) for C & C++
https://www.flecs.dev
Other
6.47k stars 454 forks source link

component's type_entity is over 1<<32, and system will crash. #1018

Closed Esp9527 closed 1 year ago

Esp9527 commented 1 year ago

Describe the bug component's type_entity is over 1<<32, and system will crash. version: flecs-3.2.5 or older

To Reproduce

`

    #include "flecs.h"
    struct Data{
        int i = 0;
    };

    template<int i>
    struct TP{
        int v;
    };

    template<int i>
    void Register(flecs::world& world) {
        if constexpr( i > 0) {
            world.component<TP<i>>();
            Register<i-1>(world);
        }
    }

    int main() {
        flecs::world world;

        Register<300>(world);

        auto e = world.entity();
        e.destruct();

        // d will use e's recycled-id (with high id)!
        flecs::entity d = world.component<Data>();

        world.system<Data>()
                .each([](Data& data){});  // will crash

        world.app().run();
        return 0;
    }

`

SanderMertens commented 1 year ago

Fixed!