Code Monkey home page Code Monkey logo

vptr's People

Contributors

ogoffart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vptr's Issues

Causes UB by creating NULL reference

This is a heads-up that the crate does not compile any more with the current Rust beta (to become stable Nov 7th). The reason is that there is UB in this const-code:

let x: &'static #ident = TransmuterPtr { int: 0 }.ptr;

References must always be non-null, dereferencable and aligned as well as point to a valid instance of T (see the Rust Reference for details). Violating that invariant is UB, and it is the responsibility of the unsafe code author to ensure that there is no UB.

Unfortunately, there never was a UB-free way to implement offsetof! in Rust. This operation is just not supported by the language right now, and the only way to fix that is to figure out what needs to change in the language to let Rust support this operation, and write an appropriate RFC. I did that and that RFC has in fact recently been accepted, but an implementation is still pending.

The memoffset crate uses an approach that's as good as we can currently make it, and we know it works with current compilers (including the latest nightly), but it could break any time as it, too, is outside the bounds of stable Rust. Also, the approach it uses does not work for CTFE; enabling that is still work-in-progress.

Is there a way for this crate to do the offset computation at run-time instead of trying to do it at compile-time? Then it could depend on memoffset to avoid this problem. I'm afraid for compile-time offsetof there is currently no solution.

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.