minetest / irrlicht

Minetest's fork of Irrlicht
Other
114 stars 87 forks source link

Invalid comparator: vector3df/vector2df operator< #266

Closed JosiahWI closed 9 months ago

JosiahWI commented 9 months ago
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include <irrlicht.h>

#include <cmath>

TEST_CASE()
{
        irr::video::S3DVertex a;
        irr::video::S3DVertex b;
        a.Pos = irr::core::vector3df{0.0125, 0.0f, 0.0f};
        b.Pos = irr::core::vector3df{0.0126, 0.0f, 0.0f};
        CHECK(a != b);
        CHECK(a < b);
        CHECK(!(b < a));
}

image

This is the cause of minetest/minetest#14132.

sfan5 commented 9 months ago

Where's the bug here?

JosiahWI commented 9 months ago

a != b, a < b, and b < a are all true at the same time. That doesn't make any sense, and it leads to incorrect sorting logic when used in STL containers.

JosiahWI commented 9 months ago

I take that back. This is the correct result of the test.