Entt: runtime_view assertion failed on windows (invalid comparator)

Created on 1 Jul 2018  路  11Comments  路  Source: skypjack/entt

Hello,

I'm sorry the implementation seem's to be broken only on windows:

capture d ecran 2018-07-01 a 23 32 52
capture d ecran 2018-07-01 a 23 33 40
capture d ecran 2018-07-01 a 23 33 58
capture d ecran 2018-07-01 a 23 34 16

solution:
https://stackoverflow.com/questions/45966807/%D0%A1-invalid-comparator-assert
https://stackoverflow.com/questions/979759/operator-and-strict-weak-ordering

This compiler is a bananana

Tell me when you will have a possible patch i will modify the library directly on windows to test it !

bug

Most helpful comment

it's also work with the new snippet ! congratulation

All 11 comments

The best part is that appveyor works as a charm. :1st_place_medal:
I think I'll fix it tomorrow, even though I'm not sure about it.

You are so lucky xD, i will try on my computer your solutions if you want, i don't know what is the problem exactly but is probably the operator< which is mixed with other operators, to hard for msvc to parse and understand xD

capture d ecran 2018-07-01 a 23 47 27

this is the result from my ci, (im using jenkins with ctest) (if you are using googletest and just ./test it's will not complain)

No, it's my fault probably. Not sure the comparator respects the strict weak ordering actually. I forgot the constraint, this isn't the first time, shame on me!

I'm from mobile and it's midnight here, so... Btw, something like this probably could work:

    RuntimeView(pattern_type others) ENTT_NOEXCEPT
        : pools{std::move(others)}
    {
        auto it = std::find_if(pools.begin(), pools.end(), [](const auto *view) { return view == nullptr; });

        if(it == pools.end()) {
            it = std::min_element(pools.begin(), pools.end(), [](const auto *lhs, const auto *rhs) {
                return lhs->size() < rhs->size();
            });
        }

        // brings the best candidate (if any) on front of the vector
        std::rotate(pools.begin(), it, pools.end());
    }

I'll wrap my mind around the issue tomorrow morning otherwise.

my test pass with this snippet !

Thank's you !

Will wait for tommorow for a possible merge + mini tag 2.7.1

Wow, I did it? One shot, one kill!! Come on!!
Yeah, tomorrow I'll cut a new release for sure.
Thanks for pointing out the error.

Yeah, i'm surprised that's other compiler doesn't complain about this error.

You shouldn't be surprised. The standard doesn't mandate for an error. It's undefined behavior if the compare function doesn't respect the constraints.
This time Microsoft helped us by detecting it even though it wasn't mandatory.

May I ask you to try this one?

    RuntimeView(pattern_type others) ENTT_NOEXCEPT
        : pools{std::move(others)}
    {
        const auto it = std::min_element(pools.begin(), pools.end(), [](const auto *lhs, const auto *rhs) {
            return (!lhs && rhs) || (lhs && rhs && lhs->size() < rhs->size());
        });

        // brings the best candidate (if any) on front of the vector
        std::rotate(pools.begin(), it, pools.end());
    }

Not sure it works (I'm writing it on the bus while going to work), but it's a slightly faster alternative to the _midnight snippet_.

Thank you.

it's also work with the new snippet ! congratulation

Upstream. Thank you for your help.

Was this page helpful?
0 / 5 - 0 ratings