• SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      47
      ·
      edit-2
      1 year ago

      It’s utilizing an obscure bug in the Rust compiler that unfortunately lets you circumvent the safety guarantees in order to produce undefined behavior - it’s mostly just a joke though, you will not run into the bug in normal code

      • porgamrer
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        Thanks for clarifying. Do you know what the bug is? I gathering it’s something to do with enums and boxing to enable a “safe” transmute, but couldn’t make sense of the code.

        Scary compiler edge cases with value-type enums aren’t surprising though. Trying to implement that feature with memory safety and high performance sounds like a nightmare.

    • TWeaK@lemm.ee
      link
      fedilink
      English
      arrow-up
      11
      arrow-down
      1
      ·
      1 year ago

      My thoughts exactly!

      Now, with cve-rs, you can corrupt your program’s memory without corrupting your program’s memory.