Commit bf1d83482b

pfg <pfg@pfg.pw>
2020-09-03 07:28:37
"Support" allocating 0 bit types
1 parent fb3c5b8
Changed files (1)
lib
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];
 }