Comment by bruckie
19 hours ago
I assumed that it meant that if you ran code at compile time or at runtime, the results should be exactly the same given the same inputs.
19 hours ago
I assumed that it meant that if you ran code at compile time or at runtime, the results should be exactly the same given the same inputs.
And they believe Zig comptime wouldn’t do that? For the same inputs? I’d love an example.
Traditional stuff in this space are:
* floating point differences between the build machine and the target. By far the most common
* endiannes - code assumes little median runs on big endian
There’s other more subtle issues that can crop up but those are the big two.
Not saying I agree though - those can happen anyway when you run on two different machines anyway.
Zig Comptime is softfloat
I get it now. Important things but not things that I use often - hopefully addressed by 1.0.
8 replies →
Doesn't comptime run under the target's float and endianness semantics? I need to check, but I believe they emulate the target when evaluating.
1 reply →
sin(x) can produce different results at comptime and runtime. In Rust there is no sin(x) at comptime for precisely this reason.
Interesting, I hadn’t run across that but that’s probably just my problem domain. I did find this bug that looks like it was resolved a year ago https://github.com/ziglang/zig/issues/24184 and I have also read they are doing some other work on floating point that will hopefully address other cross-platform inconsistencies.