GithubHelp home page GithubHelp logo

Comments (5)

RalfJung avatar RalfJung commented on August 16, 2024

from miri.

LunarLambda avatar LunarLambda commented on August 16, 2024

I thought Miri already tracks the "true type" of each pointed-to object/"alloc" for other purposes?

Also, I know ZST-transmutes are fine, but I don't see how creating a mismatched trait object is equivalent?

Unless you're suggesting that dispatching via the wrong vtable for the erased type is okay as long as an equivalent transmute between the two recipient types would be valid?

Or put another way, my code is the same as casting &Leas to &Gold and then that to &dyn Any? That seems like a pretty strong thing to allow, but I guess I don't have a counterargument, since the size and alignment fields in the vtable have to match, but that's also true for transmuting &T to &U in general.

from miri.

RalfJung avatar RalfJung commented on August 16, 2024

I thought Miri already tracks the "true type" of each pointed-to object/"alloc" for other purposes?

There is no such thing as the "true type" of an object. In memory, there are just bytes. The bytes are a bit more fancy than you may be used to, but they are still fundamentally untyped.

from miri.

RalfJung avatar RalfJung commented on August 16, 2024

Unless you're suggesting that dispatching via the wrong vtable for the erased type is okay as long as an equivalent transmute between the two recipient types would be valid?

Yes, that is a good way to put it -- that's what Miri currently implements. (Note that the wrong vtable still has to be for the same trait as the original vtable, otherwise Miri will immediately complain.) I don't think @rust-lang/opsem has made an official decision on this, but this seems most consistent with our general stance on memory being untyped.

Closing as not-a-bug.

from miri.

LunarLambda avatar LunarLambda commented on August 16, 2024

got it, thank you! very interesting.

from miri.

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.