News for hackers. Stuff that matters.
Re:The C++ standard for the F-35 Fighter Jet [video] by YesBox on Sunday December 07, 2025 @09:45PM (#46187743)
Same. I go one step further and create a macro _STOP which is defined as w/e your language's DebugBreak() is. And if it's really important, _CRASH (this coerces me to fix the issue immediately)
Re:The C++ standard for the F-35 Fighter Jet [video] by creato on Sunday December 07, 2025 @10:01PM (#46187836)
The "standard" (typically defined in projects I'm familiar with, and as of C23, an actual standard) is "unreachable": https://en.cppreference.com/w/c/program/unreachable.html
Re:The C++ standard for the F-35 Fighter Jet [video] by vlovich123 on Sunday December 07, 2025 @11:18PM (#46188241)
That is not the same thing at all. Unreachable means that entire branch cannot be taken and the compiler is free to inject optimizations assuming that’s the case. It doesn’t need to crash if the violation isn’t met - indeed it probably won’t. It’s the equivalent of having something like

    x->foo();
    if (x == null) {
        Return error…;
    }
This literally caused a security vulnerability in the Linux kernel because it’s UB to dereference null (even in the kernel where engineers assumed it had well defined semantics) and it elided the null pointer check which then created a vulnerability.

I would say that using unreachable() in mission critical software is super dangerous, moreso than an allocation failing. You want to remove all potential for UB (ie safe rust with no or minimal unsafe, not sprinkling in UB as a form of documentation).

Re:The C++ standard for the F-35 Fighter Jet [video] by creato on Monday December 08, 2025 @01:05AM (#46188922)
You're right, the thing I linked to do does exactly that. I should have read it more closely.

The projects that I've worked on, unconditionally define it as a thing that crashes (e.g. `std::abort` with a message). They don't actually use that C/C++ thing (because C23 is too new), and apparently it would be wrong to do so.

Re:The C++ standard for the F-35 Fighter Jet [video] by uecker on Monday December 08, 2025 @04:53AM (#46190411)
You can use the standard feature with the unreachable sanitizer: https://godbolt.org/z/3hePd18Tn
Re:The C++ standard for the F-35 Fighter Jet [video] by skepti on Monday December 08, 2025 @03:26AM (#46189769)
For many types of projects and approaches, avoiding UB is necessary but not at all sufficient. It's perfectly possible to have critical bugs that can cause loss of health or life or loss of millions of dollars, without any undefined behavior being involved.

Funnily enough, Rust's pattern matching, an innovation among systems languages without GCs (a small space inhabited by languages like C, C++ and Ada), may matter more regarding correctness and reliability than its famous borrow checker.

Re:The C++ standard for the F-35 Fighter Jet [video] by zozbot234 on Monday December 08, 2025 @03:40AM (#46189879)
Didn't PASCAL have variant record types with a kind of primitive pattern matching already?
Re:The C++ standard for the F-35 Fighter Jet [video] by skepti3 on Monday December 08, 2025 @06:41AM (#46191151)
Possibly, I am not sure, though Delphi, a successor language, doesn't seem to advertise itself as having pattern matching.

Maybe it is too primitive to be considered proper pattern matching, as pattern matching is known these days. Pattern matching has actually evolved quite a bit over the decades.

Re:The C++ standard for the F-35 Fighter Jet [video] by YesBox on Sunday December 07, 2025 @10:05PM (#46187855)
C++ keeps getting bigger and bigger :D

Thanks for sharing

Re:The C++ standard for the F-35 Fighter Jet [video] by creato on Sunday December 07, 2025 @11:01PM (#46188147)
This is actually C and C++ has not done something similar AFAIK.
Re:The C++ standard for the F-35 Fighter Jet [video] by hn_go_brrrrr on Monday December 08, 2025 @03:35AM (#46189837)
Fortunately the major compiler vendors all have. Routing around the standards committee is getting more and more common.
Re:The C++ standard for the F-35 Fighter Jet [video] by Fulgen on Monday December 08, 2025 @05:50AM (#46190840)
Re:The C++ standard for the F-35 Fighter Jet [video] by TuxSH on Monday December 08, 2025 @06:22AM (#46191037)
C++23 does have std::unreachable (as a function), and its counterpart [[assume(expr)]]