std.mem.zeroes use std.mem.set instead of @memset

stage1 comptime is not smart enough to remeber the size of the casted
item which leads to out of bounds errors.
This commit is contained in:
Vexu 2020-07-16 17:05:14 +03:00
parent 37647375dc
commit 06c08e5219
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC

View File

@ -552,7 +552,7 @@ pub fn zeroes(comptime T: type) T {
if (@sizeOf(T) == 0) return T{};
if (comptime meta.containerLayout(T) == .Extern) {
var item: T = undefined;
@memset(@ptrCast([*]u8, &item), 0, @sizeOf(T));
set(u8, asBytes(&item), 0);
return item;
} else {
var structure: T = undefined;