GithubHelp home page GithubHelp logo

Comments (2)

smallnest avatar smallnest commented on September 22, 2024

Yes, theoretically it seems (*V)(expunged) violates unsafe package rules as you mentioned,but here it is trick that we use the expunged as immutable and we don't change its bytes. It only acts as a special value to indicate values in map are deleted, so I personally think it is not a problem.

Why not use unsafe.Pointer? I hope this code can keep up to changes in go official repository.
There is another generic sync.Map to use unsafe.Pointer https://github.com/go-typ/typ/blob/main/sync2/map.go#L78

from exp.

DmitriyMV avatar DmitriyMV commented on September 22, 2024

It only acts as a special value to indicate values in map are deleted, so I personally think it is not a problem.

It doesn't matter that you are not reading or writing it - the compiler make no promises about not inspecting the value after the conversion. And since V can be bigger than any it can go very bad very fast and will be very hard to catch.

I hope this code can keep up to changes in go official repository.

You can always ask them about safety of certain operations.

from exp.

Related Issues (4)

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.