From 9c7fa358c11bbb49f2e624cf81c5003e39fbcd92 Mon Sep 17 00:00:00 2001 From: Christian Flicker <70640214+cflicker@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:07:21 +0100 Subject: [PATCH] std.Thread: fix off-by-one in PosixThreadImpl (#18711) by removing ZST special case --- lib/std/Thread.zig | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index ccb9af55a2..a90d775152 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -674,11 +674,6 @@ const PosixThreadImpl = struct { const Instance = struct { fn entryFn(raw_arg: ?*anyopaque) callconv(.C) ?*anyopaque { - // @alignCast() below doesn't support zero-sized-types (ZST) - if (@sizeOf(Args) < 1) { - return callFn(f, @as(Args, undefined)); - } - const args_ptr: *Args = @ptrCast(@alignCast(raw_arg)); defer allocator.destroy(args_ptr); return callFn(f, args_ptr.*); @@ -703,7 +698,7 @@ const PosixThreadImpl = struct { &handle, &attr, Instance.entryFn, - if (@sizeOf(Args) > 1) @as(*anyopaque, @ptrCast(args_ptr)) else undefined, + @ptrCast(args_ptr), )) { .SUCCESS => return Impl{ .handle = handle }, .AGAIN => return error.SystemResources,