authorgravatar for pfg@pfg.pwpfg <pfg@pfg.pw> 2020-09-02 22:28:37-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-09-02 22:28:37-07:00
logbf1d83482b581e49499e545cc625155c1043ef0c
tree88282849a586f54798e64458db4311193aa6c72d
parentfb3c5b84ede6fa48949c8069bf735ac67ec21091
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

"Support" allocating 0 bit types


1 files changed, 1 insertions(+), 1 deletions(-)

lib/std/mem/Allocator.zig+1-1
...@@ -159,7 +159,7 @@ fn moveBytes(...@@ -159,7 +159,7 @@ fn moveBytes(
159/// Returns a pointer to undefined memory.159/// Returns a pointer to undefined memory.
160/// Call `destroy` with the result to free the memory.160/// Call `destroy` with the result to free the memory.
161pub fn create(self: *Allocator, comptime T: type) Error!*T {161pub fn create(self: *Allocator, comptime T: type) Error!*T {
162 if (@sizeOf(T) == 0) return &(T{});162 if (@sizeOf(T) == 0) return @as(*T, undefined);
163 const slice = try self.allocAdvancedWithRetAddr(T, null, 1, .exact, @returnAddress());163 const slice = try self.allocAdvancedWithRetAddr(T, null, 1, .exact, @returnAddress());
164 return &slice[0];164 return &slice[0];
165}165}