zig
zig copied to clipboard
Division safety issue not reported in stage2 for minInt / -1
Zig Version
0.11.0-dev.49+b19161ba9
Steps to Reproduce and Observed Behavior
const std = @import("std");
test "overflow" {
const x = std.math.minInt(i8) / @as(i8, -1);
std.debug.print("{}\n", .{x});
}
Succeeds and prints -128, even in Debug builds.
Expected Behavior
-fstage1 correctly outputs:
error: operation caused overflow
but stage2 does not.
-128 / -1 = 128, which does not fit in an i8