Skip to content

Commit 39536a6

Browse files
committed
Allocator/Random: document that comparing ptr may result in illegal behavior
See #21756 and #17704
1 parent 9b729c1 commit 39536a6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/std/Random.zig

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ pub const RomuTrio = @import("Random/RomuTrio.zig");
2929
pub const SplitMix64 = @import("Random/SplitMix64.zig");
3030
pub const ziggurat = @import("Random/ziggurat.zig");
3131

32+
/// Any comparison of this field may result in illegal behavior, since it may be set to
33+
/// `undefined` in cases where the random implementation does not have any associated
34+
/// state.
3235
ptr: *anyopaque,
3336
fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
3437

lib/std/mem/Allocator.zig

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ const builtin = @import("builtin");
1010
pub const Error = error{OutOfMemory};
1111
pub const Log2Align = math.Log2Int(usize);
1212

13-
// The type erased pointer to the allocator implementation
13+
/// The type erased pointer to the allocator implementation.
14+
/// Any comparison of this field may result in illegal behavior, since it may be set to
15+
/// `undefined` in cases where the allocator implementation does not have any associated
16+
/// state.
1417
ptr: *anyopaque,
1518
vtable: *const VTable,
1619

0 commit comments

Comments
 (0)