commit bf1d83482b581e49499e545cc625155c1043ef0c (tree)
parent fb3c5b84ede6fa48949c8069bf735ac67ec21091
Author: pfg <pfg@pfg.pw>
Date: Wed, 2 Sep 2020 22:28:37 -0700
"Support" allocating 0 bit types
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig
@@ -159,7 +159,7 @@ fn moveBytes(
/// Returns a pointer to undefined memory.
/// Call `destroy` with the result to free the memory.
pub fn create(self: *Allocator, comptime T: type) Error!*T {
- if (@sizeOf(T) == 0) return &(T{});
+ if (@sizeOf(T) == 0) return @as(*T, undefined);
const slice = try self.allocAdvancedWithRetAddr(T, null, 1, .exact, @returnAddress());
return &slice[0];
}