News for hackers. Stuff that matters.
Re:Rusty.hpp: A Borrow Checker and Memory Ownership System f... by tialaramex on Sunday May 05, 2024 @07:30AM (#40264037)
You're describing what it would do in a sane world where WG21 cared about safety.

In this world, as the document you've linked says: "The behavior is undefined if *this does not contain a value."

The operators for such access are actually `noexcept` - the exception you're apparently relying on would be illegal.

Re:Rusty.hpp: A Borrow Checker and Memory Ownership System f... by kzrdude on Sunday May 05, 2024 @07:40AM (#40264094)
Can we salvage this by forbidding * on optional with compiler warnings (as errors)?
Re:Rusty.hpp: A Borrow Checker and Memory Ownership System f... by lorenzhs on Monday May 06, 2024 @07:06AM (#40273265)
clang-tidy has a check for this -- it's not a compiler check but with clangd and LSP, almost every code editor can show an inline warning: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/unch...
Re:Rusty.hpp: A Borrow Checker and Memory Ownership System f... by lorenzhs on Sunday May 05, 2024 @03:18PM (#40267395)
Should’ve checked my own link instead of relying on memory — I might have some code to revisit on Monday. That’s insane, thanks for correcting me!
Re:Rusty.hpp: A Borrow Checker and Memory Ownership System f... by tialaramex on Sunday May 05, 2024 @09:02PM (#40270133)
No problem, if I caused you to fix a bug before it happened that's great. Yes, I find that reading sources I'm about to cite is often eye-opening. Our memories are not as good as we think they are, and our condensed understanding of a complex situation may have ignored something which is now crucial.

Once in a while I go down a rabbit hole, but hey, it's not as though HN isn't a rabbit hole anyway.