| author | |
| committer | |
| log | 629aa10c5672926eb5f8494296f5d5492cc2833f |
| tree | 59db310d0a3317ff76f24d44598146fb794c73c4 |
| parent | 5dddb45ec71ae93750fddda932ef8b7d2ffa293d |
closes #4303 files changed, 11 insertions(+), 7 deletions(-)
src/codegen.cpp+1-1| ... | ... | @@ -1879,7 +1879,7 @@ static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutable *executable, I |
| 1879 | 1879 | static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutable *executable, |
| 1880 | 1880 | IrInstructionUnreachable *unreachable_instruction) |
| 1881 | 1881 | { |
| 1882 | if (ir_want_debug_safety(g, &unreachable_instruction->base) || g->is_test_build) { | |
| 1882 | if (ir_want_debug_safety(g, &unreachable_instruction->base)) { | |
| 1883 | 1883 | gen_debug_safety_crash(g, PanicMsgIdUnreachable); |
| 1884 | 1884 | } else { |
| 1885 | 1885 | LLVMBuildUnreachable(g->builder); |
std/debug.zig+9-1| ... | ... | @@ -12,7 +12,15 @@ error InvalidDebugInfo; |
| 12 | 12 | error UnsupportedDebugInfo; |
| 13 | 13 | |
| 14 | 14 | pub fn assert(ok: bool) { |
| 15 | if (!ok) unreachable // assertion failure | |
| 15 | if (!ok) { | |
| 16 | // In ReleaseFast test mode, we still want assert(false) to crash, so | |
| 17 | // we insert an explicit call to @panic instead of unreachable. | |
| 18 | if (builtin.is_test) { | |
| 19 | @panic("assertion failure") | |
| 20 | } else { | |
| 21 | unreachable // assertion failure | |
| 22 | } | |
| 23 | } | |
| 16 | 24 | } |
| 17 | 25 | |
| 18 | 26 | var panicking = false; |
std/special/compiler_rt/index.zig+1-5| ... | ... | @@ -17,6 +17,7 @@ comptime { |
| 17 | 17 | |
| 18 | 18 | const builtin = @import("builtin"); |
| 19 | 19 | const is_test = builtin.is_test; |
| 20 | const assert = @import("../../debug.zig").assert; | |
| 20 | 21 | |
| 21 | 22 | const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4; |
| 22 | 23 | |
| ... | ... | @@ -292,8 +293,3 @@ fn test_one_udivsi3(a: u32, b: u32, expected_q: u32) { |
| 292 | 293 | const q: u32 = __udivsi3(a, b); |
| 293 | 294 | assert(q == expected_q); |
| 294 | 295 | } |
| 295 | ||
| 296 | ||
| 297 | fn assert(ok: bool) { | |
| 298 | if (!ok) unreachable; | |
| 299 | } |