Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Invalid comparator: vector3df/vector2df operator< #266

Closed
JosiahWI opened this issue Dec 20, 2023 · 3 comments
Closed

Invalid comparator: vector3df/vector2df operator< #266

JosiahWI opened this issue Dec 20, 2023 · 3 comments

Comments

@JosiahWI
Copy link
Contributor

#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
Copy link
Member

sfan5 commented Dec 20, 2023

Where's the bug here?

@JosiahWI
Copy link
Contributor Author

JosiahWI commented Dec 20, 2023

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
Copy link
Contributor Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants