GithubHelp home page GithubHelp logo

Comments (6)

skypjack avatar skypjack commented on August 24, 2024

Interesting. I've clang-tidy enabled and cannot reproduce it though.
Can I ask you what param triggers the error? Maybe it's not the only one.

from entt.

jonesmz avatar jonesmz commented on August 24, 2024

It's this PR: https://github.com/TheOpenSpaceProgram/osp-magnum/pull/269/files , the file test/tasks/main.cpp which is the very bottom-most file in the review (at the time of writing).

The deprecation message says to switch from ::at(index) to ::begin()[index], but i was actually able to switch to simply ::operator[](index) directly.

However, originally (before i just switched to ::operator[](index))when i switched from ::at(index) to ::begin()[index] i got the warning from clang tidy i reported in my initial comment.

The types are:

'entt::internal::sparse_set_iterator<std::vector<osp::TaskId>>::difference_type', where osp::TaskId is an enum-class backed by a uint32_t.

https://github.com/TheOpenSpaceProgram/osp-magnum/blob/a747cab17ae3f5bea02a800c8b9cfbe8a1e345c3/src/osp/tasks/tasks.h#L67-L72

difference_type should be std::ptrdiff_t but apparently cpp reference thinks the only requirement is that it's a signed integer. Regardless, it's being calculated on my platform as long.

rRand is type std::mt19937 &rRand defined here: https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine

which apparently returns std::uint_fast32_t and i guess on the github actions runner is of type unsigned long.

runTasksLeft is auto const runTasksLeft = rExec.tasksQueuedRun.size(); which i imagine is std::size_t, though i'm not 100% sure what the type of tasksQueuedRun is off of the top of my head.

The full function is here:

https://github.com/TheOpenSpaceProgram/osp-magnum/blob/a747cab17ae3f5bea02a800c8b9cfbe8a1e345c3/test/tasks/main.cpp#L51-L73

since unsigned long can't convert to long without precision loss, we get the warning about narrowing conversions.

My recommendation is that you can either make the functions for sparse_set_iterator templated on the std::integral concept, or you can define two versions, one for signed integers and another for unsigned.

But don't fix this on my account, since ::operator[](index) works for me just fine. I just wanted to report the warning in case you wanted to fix it.

from entt.

skypjack avatar skypjack commented on August 24, 2024

Ohoo, I see, so the error is at the call site in your case and not in the body of the function, is it?
I got it the other way around initially. This would explain why it doesn't trigger on the CI at least.

from entt.

skypjack avatar skypjack commented on August 24, 2024

I checked the standard and a few implementations for the major compilers.
As expected, operator[] for random access iterators is always defined in terms of difference_type.
Therefore, I think I'll stick with the current implementation. Thanks for bringing it up though. 👍

from entt.

jonesmz avatar jonesmz commented on August 24, 2024

Do you mind sharing some of the random access iterators that you were looking at? I'm curious.

from entt.

skypjack avatar skypjack commented on August 24, 2024

You can check a few implementations here (working draft for the language). Then I checked the MSVC one from within VS (just look into the implementation of a container like the vector) and the ones offered by clang (easily available online). 👍

from entt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.