Skip to content

Commit 9c7fa35

Browse files
authored
std.Thread: fix off-by-one in PosixThreadImpl (#18711)
by removing ZST special case
1 parent 7b45611 commit 9c7fa35

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

lib/std/Thread.zig

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,6 @@ const PosixThreadImpl = struct {
674674

675675
const Instance = struct {
676676
fn entryFn(raw_arg: ?*anyopaque) callconv(.C) ?*anyopaque {
677-
// @alignCast() below doesn't support zero-sized-types (ZST)
678-
if (@sizeOf(Args) < 1) {
679-
return callFn(f, @as(Args, undefined));
680-
}
681-
682677
const args_ptr: *Args = @ptrCast(@alignCast(raw_arg));
683678
defer allocator.destroy(args_ptr);
684679
return callFn(f, args_ptr.*);
@@ -703,7 +698,7 @@ const PosixThreadImpl = struct {
703698
&handle,
704699
&attr,
705700
Instance.entryFn,
706-
if (@sizeOf(Args) > 1) @as(*anyopaque, @ptrCast(args_ptr)) else undefined,
701+
@ptrCast(args_ptr),
707702
)) {
708703
.SUCCESS => return Impl{ .handle = handle },
709704
.AGAIN => return error.SystemResources,

0 commit comments

Comments
 (0)