diff options
| author | Shawn Landden <shawn@git.icu> | 2019-11-04 17:41:45 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-11-05 11:38:32 -0500 |
| commit | 1c22cb5e515548b22ccb260f4451edc119151584 (patch) | |
| tree | 719a20198cfb2963afb5799008c0557fddf3e2b0 | |
| parent | 55685ae7801a222ddaaf46660dd0acfa34ed71f4 (diff) | |
| download | zig-1c22cb5e515548b22ccb260f4451edc119151584.tar.gz zig-1c22cb5e515548b22ccb260f4451edc119151584.zip | |
fix noreturn function that may return.
we do not want undefined behavior here in --release-fast
and --release-small modes
| -rw-r--r-- | lib/std/special/c.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index a9fd9857ff..473d2d4e33 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -82,9 +82,11 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn if (builtin.is_test) { @setCold(true); std.debug.panic("{}", msg); - } else { - unreachable; } + if (builtin.os != .freestanding) { + std.os.abort(); + } + while (true) {} } export fn memset(dest: ?[*]u8, c: u8, n: usize) ?[*]u8 { |
