From f082e253b56b98a806e5ec047c5eb197b2c8ab88 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 1 Mar 2020 01:17:50 -0500 Subject: [PATCH] fix native OS version detection on macOS closes #4583 --- lib/std/zig/system.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 5767291de7..df50b4a4c2 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -232,7 +232,7 @@ pub const NativeTargetInfo = struct { // supports std.os.sysctlbynameC( "kern.osproductversion", - &product_version[0], + &product_version, &size, null, 0, @@ -241,7 +241,8 @@ pub const NativeTargetInfo = struct { else => unreachable, }; - if (std.builtin.Version.parse(product_version[0..size])) |ver| { + const string_version = product_version[0 .. size - 1 :0]; + if (std.builtin.Version.parse(string_version)) |ver| { os.version_range.semver.min = ver; os.version_range.semver.max = ver; } else |err| switch (err) {