Prevent Zig from reordering instructions (opens in new tab)
Is there any way currently to prevent the Zig compiler from “optimizing” by reordering function calls? const res = funcWithSideEffects(); dealWithSideEffects(); return res; In this snippet I’d expect the first function to always be executed first, which happens in Debug mode but in certain architectures in release does not. Note: the non-generic context has to do with calling a FPU instruction called rint that can set an exception flag on the FPU which Zig does not known about, so it thinks ...
Read the original article