From d7c6cfa7fdf51f0b52aa3666aaa3022bd8e4876f Mon Sep 17 00:00:00 2001 From: xdBronch <51252236+xdBronch@users.noreply.github.com> Date: Thu, 6 Jul 2023 13:43:50 -0400 Subject: std.mem.zeroes work with allowzero pointers --- lib/std/mem.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/std') diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 489fec7ea1..13152496b3 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -276,7 +276,8 @@ pub fn zeroes(comptime T: type) T { return null; }, .One, .Many => { - @compileError("Can't set a non nullable pointer to zero."); + if (ptr_info.is_allowzero) return @ptrFromInt(0); + @compileError("Only nullable and allowzero pointers can be set to zero."); }, } }, -- cgit v1.2.3