▲ | tempodox 4 days ago | |
> Here unreacheable() is the new macro from C23 (and C++23) that makes the behaviour undefined whenever the branch of the invocation is reached. I cannot, in good conscience, use a technology that adds even more undefined behavior. Instead it reinforces my drive to avoid C whenever I can and use OCaml or Rust instead. | ||
▲ | 1718627440 4 days ago | parent | next [-] | |
I think it is good to explicitly invoke UB. It makes it much more obvious in the code, where it is intended and where not. It's a way to specify that this point in code is never reached, the code can't deal with it and I don't even care what the compiler does in this case. It's also a good thing to tell the compiler that the programmer intends that this case will never happen, so that the static analyzer can point out ways through the code, where it actually does. | ||
▲ | aw1621107 3 days ago | parent | prev [-] | |
For what it's worth, Rust has std::hint::unreachable_unchecked() which does exactly the same thing. |