Closed jeffkdev closed 4 years ago
The failure with "Illegal Operation" is a 2nd issue that should also be solved.
The C code has Undefined Behavior. Those are signed ints. Zig does honor wrapping arithmetic for unsigned ints.
Doh! Sorry about that - completely misread the C type. Very nice of Zig to catch this undefined behavior :)
Use case is this file: https://github.com/smcameron/open-simplex-noise-in-c/blob/master/open-simplex-noise.c#L195 Crashes on line 195 with "Illegal Operation" in debug mode only. Ran translate-c, below is a snippet of what it generates:
Basically the C code depends on the defined wrap-around behavior for unsigned integers, but the generated Zig code uses the standard operators. Can be reproduced by running: zig translate-c open-simplex-noise.c
0.5.0 +a6f6d8d2f