diff options
| author | Christian Flicker <70640214+cflicker@users.noreply.github.com> | 2024-01-29 17:07:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-29 11:07:21 -0500 |
| commit | 9c7fa358c11bbb49f2e624cf81c5003e39fbcd92 (patch) | |
| tree | b11ac5c7b32aaba673dbe695e5956d9b592f01ab /lib/std/Thread.zig | |
| parent | 7b4561170a202c9929f5e61517f1bedaa0b60db6 (diff) | |
| download | zig-9c7fa358c11bbb49f2e624cf81c5003e39fbcd92.tar.gz zig-9c7fa358c11bbb49f2e624cf81c5003e39fbcd92.zip | |
std.Thread: fix off-by-one in PosixThreadImpl (#18711)
by removing ZST special case
Diffstat (limited to 'lib/std/Thread.zig')
| -rw-r--r-- | lib/std/Thread.zig | 7 |
1 files changed, 1 insertions, 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, |
