authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-01-31 02:04:02-08:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-02-03 17:07:28-08:00
log4041cc06d5a0327c6d6d7e0bdec8516df06cb5ba
treee8a804a5805f41ffb4ffc93098ce06144b88e3f6
parentb46f9945a81012ecd3ceca7152dd6faadf4815c9

Allocator/Random: document that comparing `ptr` may result in illegal behavior

See #21756 and #17704

2 files changed, 7 insertions(+), 1 deletions(-)

lib/std/Random.zig+3
......@@ -29,6 +29,9 @@ pub const RomuTrio = @import("Random/RomuTrio.zig");
2929pub const SplitMix64 = @import("Random/SplitMix64.zig");
3030pub 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.
3235ptr: *anyopaque,
3336fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
3437
lib/std/mem/Allocator.zig+4-1
......@@ -10,7 +10,10 @@ const builtin = @import("builtin");
1010pub const Error = error{OutOfMemory};
1111pub 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.
1417ptr: *anyopaque,
1518vtable: *const VTable,
1619