translate-c: incorrect handling of negative divisor in remainder operator #10176
Labels
bug
Observed behavior contradicts documented or intended behavior
translate-c
C to Zig source translation feature (@cImport)
Milestone
Remember to search before filing a new report
Zig Version
0.9.0-dev.1679+6cf8a49bb
Steps to Reproduce
Run
zig translate-c
on the following code:And then
zig run
on the outputExpected Behavior
From the C standard:
If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a.
So in this case x should equal 1 and the program should exit normally.Actual Behavior
Compile error:
Also, if the divisor is a runtime value instead of a comptime-known one, the result is a panic at runtime.
The text was updated successfully, but these errors were encountered: