| author | |
| committer | |
| log | ca4ee9ae73559062da24937ef4a7376d9d27bbeb |
| tree | 6ce300088901bac66f7bdbc10328369bb5d366f5 |
| parent | 60958d135f74662e2c7d4a7f80c582a647fa07b6 |
| signature |
Fixes #184152 files changed, 20 insertions(+), 1 deletions(-)
src/Sema.zig+4-1| ... | ... | @@ -16019,9 +16019,12 @@ fn analyzeArithmetic( |
| 16019 | 16019 | }; |
| 16020 | 16020 | |
| 16021 | 16021 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 16022 | ||
| 16022 | 16023 | if (block.wantSafety() and want_safety and scalar_tag == .Int) { |
| 16023 | 16024 | if (mod.backendSupportsFeature(.safety_checked_instructions)) { |
| 16024 | _ = try sema.preparePanicId(block, .integer_overflow); | |
| 16025 | if (air_tag != air_tag_safe) { | |
| 16026 | _ = try sema.preparePanicId(block, .integer_overflow); | |
| 16027 | } | |
| 16025 | 16028 | return block.addBinOp(air_tag_safe, casted_lhs, casted_rhs); |
| 16026 | 16029 | } else { |
| 16027 | 16030 | const maybe_op_ov: ?Air.Inst.Tag = switch (air_tag) { |
test/cases/no_compile_panic_for_unchecked_arith.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | pub const panic = @compileError(""); | |
| 2 | ||
| 3 | export fn entry() usize { | |
| 4 | var x: usize = 0; | |
| 5 | x +%= 1; | |
| 6 | x -%= 1; | |
| 7 | x *%= 2; | |
| 8 | x +|= 1; | |
| 9 | x -|= 1; | |
| 10 | x *|= 2; | |
| 11 | return x; | |
| 12 | } | |
| 13 | ||
| 14 | // compile | |
| 15 | // output_mode=Obj | |
| 16 | // backend=stage2,llvm |