enum.hpp source code check error
Closed
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 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 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 4 months ago
@SanderMertens This problem seems to still exist in current-master, Above is description
@SanderMertens 4 months ago
Fixed!