diff --git a/src/Air.zig b/src/Air.zig index ee6bacc06d..fbd958dece 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -1646,20 +1646,20 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool { .c_va_copy, .c_va_end, .c_va_start, + .add_safe, + .sub_safe, + .mul_safe, => true, .add, - .add_safe, .add_optimized, .add_wrap, .add_sat, .sub, - .sub_safe, .sub_optimized, .sub_wrap, .sub_sat, .mul, - .mul_safe, .mul_optimized, .mul_wrap, .mul_sat, diff --git a/test/cases/safety/ignored expression integer overflow.zig b/test/cases/safety/ignored expression integer overflow.zig new file mode 100644 index 0000000000..f8e3f0bf0a --- /dev/null +++ b/test/cases/safety/ignored expression integer overflow.zig @@ -0,0 +1,21 @@ +const std = @import("std"); + +pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { + _ = stack_trace; + if (std.mem.eql(u8, message, "integer overflow")) { + std.process.exit(0); + } + std.process.exit(1); +} + +pub fn main() !void { + var x: usize = undefined; + x = 0; + // We ignore this result but it should still trigger a safety panic! + _ = x - 1; + return error.TestFailed; +} + +// run +// backend=llvm +// target=native