Commit afe6e69e4c

Andrew Kelley <andrew@ziglang.org>
2022-07-05 01:53:41
std.Thread: fix mutable ref of temporary
The previous code is a compile error in stage2 as well as the upcoming lang spec.
1 parent 9ecc47c
Changed files (1)
lib
lib/std/Thread.zig
@@ -513,7 +513,8 @@ const WindowsThreadImpl = struct {
         errdefer assert(windows.kernel32.HeapFree(heap_handle, 0, alloc_ptr) != 0);
 
         const instance_bytes = @ptrCast([*]u8, alloc_ptr)[0..alloc_bytes];
-        const instance = std.heap.FixedBufferAllocator.init(instance_bytes).allocator().create(Instance) catch unreachable;
+        var fba = std.heap.FixedBufferAllocator.init(instance_bytes);
+        const instance = fba.allocator().create(Instance) catch unreachable;
         instance.* = .{
             .fn_args = args,
             .thread = .{