• SorryQuick@lemmy.ca
      link
      fedilink
      arrow-up
      4
      arrow-down
      3
      ·
      edit-2
      1 day ago

      The whole point of a segfault is that you can’t really know anything about it. Even in rust, when you get a segfault there is no meaningful error.

      • RoyaltyInTraining@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        11 hours ago

        The worst thing you can do in non-unsafe Rust is perform an out-of-bounds indexing operation, or anything else that panics. The error you get tells you the panic’s exact location in the source code, down to the line and column. Meanwhile, C and C++ either don’t produce an error at all when accessing uninitialized memory (which is arguably the worst behavior), or it segfaults with zero extra info.

        The only way to make Rust segfault is by performing unsafe operations, and those must always be clearly marked.

      • WhyJiffie@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        7
        arrow-down
        2
        ·
        19 hours ago

        point is, Rust manages to give you not a segfault but a meaningful error almost all the time until you use unsafe

        • SorryQuick@lemmy.ca
          link
          fedilink
          arrow-up
          2
          arrow-down
          3
          ·
          18 hours ago

          If you’re getting a segfault in C++, it’s also cause you used unsafe code. It’s just not officially enclosed in an “unsafe” block.

          • WhyJiffie@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            11 hours ago

            the point was not on the unsafe word, but a very specific feature of Rust that helps enclosing unsafe code where the compiler wouldn’t be able to 100% verify your logic. no such thing in C++. C++ does not even attempt to verify safety

            your response is basically “get better at coding dumbass, I am the safety validator”