This Issue is Not Yet on BountyBot

To start managing bounties for this repository and incentivize contributors, install our GitHub app.

enum.hpp source code check error

Closed
hallomorld avatar @hallomorld
C C
Created 5 months ago
Updated 4 months ago
4 comments
6,971

flecs 4.0.3

in enum.hpp

int index_by_value(U value) const {
    if (!impl_.max) {
// impl_,.max initlize is -1,  changed to if (imp_max < 0) ?
        return -1;
    }

Comments (4)

SanderMertens avatar
@SanderMertens 4 months ago

Verified that the code works with an additional test for empty enums. If you know of a scenario where this code fails, feel free to resubmit a bug with the reproducing code!

hallomorld avatar
@hallomorld 4 months ago

Sorry, I didn't see this message in time. This problem seems to still exist in current-master, and the following tests can be used

#include <flecs.h>
#include <iostream>

enum EmptyEnum {
};

enum OneEnum {
    OE1,
};
enum TwoEnum {
    TE1,
    TE2,
};

int main()
{
    flecs::world ecs;
    auto zero_type = flecs::enum_type<EmptyEnum>(ecs);
    test_int(zero_type.index_by_value(0), -1);

    auto one_type = flecs::enum_type<OneEnum>(ecs);
    test_int(one_type.index_by_value(0), 0);

    auto two_type = flecs::enum_type<TwoEnum>(ecs);
    test_int(two_type.index_by_value(0), 0);
    return 0;
}

test_int(one_type.index_by_value(0), 0); will fail!

hallomorld avatar
@hallomorld 4 months ago

@SanderMertens This problem seems to still exist in current-master, Above is description

SanderMertens avatar
@SanderMertens 4 months ago

Fixed!