zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit afe6e69e4cda8f5c3a11eed31015a28b1373ff20 (tree)
parent 9ecc47cd7cd5b5fbda8dc78a5d2ab41d8f0d01a8
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon,  4 Jul 2022 16:53:41 -0700

std.Thread: fix mutable ref of temporary

The previous code is a compile error in stage2 as well as the
upcoming lang spec.

Diffstat:
Mlib/std/Thread.zig | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 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 = .{