From afe6e69e4cda8f5c3a11eed31015a28b1373ff20 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 4 Jul 2022 16:53:41 -0700 Subject: std.Thread: fix mutable ref of temporary The previous code is a compile error in stage2 as well as the upcoming lang spec. --- lib/std/Thread.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/std/Thread.zig') diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index aaf0fc3440..d52515b88d 100644 --- a/lib/std/Thread.zig +++ b/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 = .{ -- cgit v1.2.3