I don’t think that casting a range of bits as some other arbitrary type “is a bug nobody sees coming”.

C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

That’s why I love C++

  • vivendi@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    9 hours ago

    No there is not. Borrow checking and RAII existed in C++ too and there is no formal axiomatic proof of their safety in a general sense. Only to a very clearly defined degree.

    In fact, someone found memory bugs in Rust, again, because it is NOT soundly memory safe.

    Dart is soundly Null-safe. Meaning it can never mathematically compile null unsafe code unless you explicitly say you’re OK with it. Kotlin is simply Null safe, meaning it can run into bullshit null conditions.

    The same thing with Rust: don’t let it lull you into a sense of security that doesn’t exist.

    • BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      4
      arrow-down
      1
      ·
      9 hours ago

      Borrow checking…existed in C++ too

      Wat? That’s absolutely not true; even today lifetime-tracking in C++ tools is still basically a research topic.

      …someone found memory bugs in Rust, again, because it is NOT soundly memory safe.

      It’s not clear what you’re talking about here. In general, there are two ways that a language promising soundness can be unsound: a bug in the compiler, or a problem in the language definition itself permitting unsound code. (unsafe changes the prerequisites for unsoundness, placing more burden on the user to ensure that certain invariants are upheld; if the code upholds these invariants, but there’s still unsoundness, then that falls into the “bug in Rust” category, but unsoundness of incorrect unsafe code is not a bug in Rust.)

      Rust has had both types of bugs. Compiler bugs can be (and are) fixed without breaking (correct) user code. Bugs in the language definition are, fortunately, fixable at edition boundaries (or in rare cases by making a small breaking change, as when the behavior of extern "C" changed).

      • vivendi@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        edit-2
        8 hours ago

        Have you heard about cve-rs?

        https://github.com/Speykious/cve-rs

        Blazingly fast memory failures with no unsafe blocks in pure Rust.

        Edit: also I wish whoever designed the syntax for rust to burn in hell for eternity

        Edit 2: Before the Cult of Rust™ sends their assassins to take out my family, I am not hating on Rust (except the syntax) and I’m not a C absolutist, I am just telling you to be aware of the limitations of your tools

          • vivendi@programming.dev
            link
            fedilink
            English
            arrow-up
            1
            arrow-down
            1
            ·
            edit-2
            7 hours ago

            A) Rust doesn’t have a formal specification other than “whatever the fuck our team hallucinated in this compiler version”

            B) Doesn’t matter the definition if it fucks your day because you’re not careful.

            Sure sure Heil Rust but be mindful of the fuck you’re doing before you get bit ¯\_ (ツ) _/¯

            • BatmanAoD@programming.dev
              link
              fedilink
              arrow-up
              2
              ·
              6 hours ago

              Rust doesn’t have a formal specification other than “whatever the fuck our team hallucinated in this compiler version”

              That’s simply not true. The Reference, while not an ISO-style formal spec, does actually specify most of the intended language behavior, and incrementally approaches completion over time. But even if you insist on an ISO-style formal spec, there’s Ferrocene: https://ferrous-systems.com/blog/the-ferrocene-language-specification-is-here/

              it fucks your day because you’re not careful

              The cve-rs vulnerability is actually not really something you’d ever write by accident. Also note that the bug report has multiple versions because, even though a “full” solution is pending some deeper compiler changes, the first two versions of the exploit are now caught by the compiler. So, like I said, the compiler bugs do get fixed over time.

          • vivendi@programming.dev
            link
            fedilink
            English
            arrow-up
            1
            arrow-down
            1
            ·
            6 hours ago

            Yeah and those are the ones currently identified (btw that issue isn’t completely fixed) because rust never was nor advertised itself as sound. Meaning, you gotta be careful when writing Rust code too. Not as much as C++, but it’s not a magical shield against memory problems like people have been shilling it as.