I’m running into an odd comptime issue when I was trying some sample code using evented + Grand Central Dispatch, and I’m not quite understanding it. I suspect this is just a standard library bug but I’m still not positive that it isn’t user error. The issue happens for me on both master (0.17.0-dev.1275+59a628c6d) and 0.16.0.
A minimal failing example (adapted from here, which also fails if copied verbatim):
const std = @import("std");
pub fn main() !void {
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
const gpa = debug_allocator.allocator();
var evented: std.Io.Evented = undefined;
try evented.init(gpa, .{
.backing_allocator_needs_mutex = false,
});
defer evented.deinit();
}
Which gives this comptime error:
Compile output❯ zig build
install
└─ install zidk
└─ compile exe zidk Debug native 1 errors
/opt/homebrew/Cellar/zig/0.16.0_1/lib/zig/std/debug.zig:420:14: error: reached unreachable code
if (!ok) unreachable; // assertion failure
^~~~~~~~~~~
/opt/homebrew/Cellar/zig/0.16.0_1/lib/zig/std/mem/Allocator.zig:445:20: note: called at comptime here
comptime assert(slice_info.size == .slice);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
deinit: /opt/homebrew/Cellar/zig/0.16.0_1/lib/zig/std/Io/Dispatch.zig:584:30
main: src/main.zig:11:25
4 reference(s) hidden; use '-freference-trace=6' to see all references
error: 1 compilation errors
failed command: /opt/homebrew/Cellar/zig/0.16.0_1/bin/zig build-exe -ODebug --dep zidk -Mroot=/Users/perry/git/zidk/src/main.zig -Mzidk=/Users/perry/git/zidk/src/root.zig --cache-dir .zig-cache --global-cache-dir /Users/perry/.cache/zig --name zidk --zig-lib-dir /opt/homebrew/Cellar/zig/0.16.0_1/lib/zig/ --listen=-
Build Summary: 0/3 steps succeeded (1 failed)
install transitive failure
└─ install zidk transitive failure
└─ compile exe zidk Debug native 1 errors
error: the following build command failed with exit code 1:
.zig-cache/o/0cd16de5dbb9d338e110e2d0aa3a08b7/build /opt/homebrew/Cellar/zig/0.16.0_1/bin/zig /opt/homebrew/Cellar/zig/0.16.0_1/lib/zig /Users/perry/git/zidk .zig-cache /Users/perry/.cache/zig --seed 0xc1fa9371 -Za691d53d472b4d28
Convenience link for Evented.deinit’s definition.
vulpesx July 9, 2026, 3:15am 2
Only Threaded is guaranteed to work, other implementations are WIP
There are also 3rd party implementations such as zio
alanza July 9, 2026, 12:06pm 3
I think the fix for this was merged recently?
https://codeberg.org/ziglang/zig/pulls/35222#issuecomment-17886197
In particular the assertion that you’re tripping should not exist on master anymore; could you try updating Zig and seeing if your minimal program still fails to compile?
Ah, good catch—I somehow didn’t notice that building with master resulting in a different (albeit similar) error message. Here’s what the compile log looks like on master (0.17.0-dev.1282+c0f9b51d8):
❯ zig build
install
└─ install newzidk
└─ compile exe newzidk Debug native 1 errors
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/debug.zig:435:14: error: reached unreachable code
if (!ok) unreachable; // assertion failure
^~~~~~~~~~~
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/mem.zig:4711:11: note: called at comptime here
assert(info.size == .slice);
~~~~~~^~~~~~~~~~~~~~~~~~~~~
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/mem.zig:4718:63: note: called at comptime here
pub fn absorbSentinel(slice: anytype) AbsorbSentinelReturnType(@TypeOf(slice)) {
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/mem/Allocator.zig:452:63: note: generic function instantiated here
const bytes: []u8 = @ptrCast(@constCast(mem.absorbSentinel(memory)));
~~~~~~~~~~~~~~~~~~^~~~~~~~
referenced by:
deinit: /Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/Io/Dispatch.zig:583:30
main: src/main.zig:11:25
4 reference(s) hidden; use '-freference-trace=6' to see all references
error: 1 compilation errors
failed command: /Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/zig build-exe -ODebug --dep newzidk -Mroot=src/main.zig -Mnewzidk=src/root.zig --cache-dir .zig-cache --global-cache-dir /Users/perry/.cache/zig --name newzidk --zig-lib-dir /Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/ --listen=-
Build Summary: 0/3 steps succeeded (1 failed)
install transitive failure
└─ install newzidk transitive failure
└─ compile exe newzidk Debug native 1 errors
alanza July 9, 2026, 6:21pm 5
Ope, that makes total sense as an error to me. I put up a PR:
https://codeberg.org/ziglang/zig/pulls/36113
Amazing; thank you kindly!!
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.