diff options
| author | pfg <pfg@pfg.pw> | 2020-09-02 22:28:37 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-02 22:28:37 -0700 |
| commit | bf1d83482b581e49499e545cc625155c1043ef0c (patch) | |
| tree | 88282849a586f54798e64458db4311193aa6c72d /lib/std | |
| parent | fb3c5b84ede6fa48949c8069bf735ac67ec21091 (diff) | |
| download | zig-bf1d83482b581e49499e545cc625155c1043ef0c.tar.gz zig-bf1d83482b581e49499e545cc625155c1043ef0c.zip | |
"Support" allocating 0 bit types
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/mem/Allocator.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index bb59de2a7e..f14373970a 100644 --- 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]; } |
