authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-02-20 03:53:42+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-02-20 12:10:29+00:00
log65a87ff299a364e7d8bab6256e0b05022f1a2620
treeabcf162300432c9b8f8c1c8ffe692f7877ce71fa
parent97290e0bfc38e75fb0e19f382a2187801bf4a458

Liveness: do not elide safety-checked instructions

Resolves: #19012

2 files changed, 24 insertions(+), 3 deletions(-)

src/Air.zig+3-3
...@@ -1646,20 +1646,20 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {...@@ -1646,20 +1646,20 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
1646 .c_va_copy,1646 .c_va_copy,
1647 .c_va_end,1647 .c_va_end,
1648 .c_va_start,1648 .c_va_start,
1649 .add_safe,
1650 .sub_safe,
1651 .mul_safe,
1649 => true,1652 => true,
16501653
1651 .add,1654 .add,
1652 .add_safe,
1653 .add_optimized,1655 .add_optimized,
1654 .add_wrap,1656 .add_wrap,
1655 .add_sat,1657 .add_sat,
1656 .sub,1658 .sub,
1657 .sub_safe,
1658 .sub_optimized,1659 .sub_optimized,
1659 .sub_wrap,1660 .sub_wrap,
1660 .sub_sat,1661 .sub_sat,
1661 .mul,1662 .mul,
1662 .mul_safe,
1663 .mul_optimized,1663 .mul_optimized,
1664 .mul_wrap,1664 .mul_wrap,
1665 .mul_sat,1665 .mul_sat,
test/cases/safety/ignored expression integer overflow.zig created+21
...@@ -0,0 +1,21 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10
11pub fn main() !void {
12 var x: usize = undefined;
13 x = 0;
14 // We ignore this result but it should still trigger a safety panic!
15 _ = x - 1;
16 return error.TestFailed;
17}
18
19// run
20// backend=llvm
21// target=native