I read on Zig Doc it has undefined behavior. is that it? isn't there any way tho predict the behavior of the code after hitting unreachable? like if it's process next line or try to continue like unreachable never been there!
What happen when program reach unreachable on ReleaseFast? (Zig lang)
433 Views Asked by Sarvarian At
2
There are 2 best solutions below
0

That's it. If you could guarantee how the code would behave in any given scenario, that would be defined behavior.
If you want to know why undefined behavior exists, see here for a start.
No, the compiler couldn't optimize as much otherwise.
Never use
unreachable
if you want to control what happens.Remember: UB is worse than unpredictability when you hit that line. The optimizer could break your program even before you arrive at the point you hit UB.