-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Zig Version
0.16.0-dev.1631+2aff85384
Steps to Reproduce and Observed Behavior
Minimal reproduction:
// main.zig
export fn repro(bytes: *[0]u8) void {
_ = @as([]const u8, "") ++ bytes;
}
❯ zig build-obj main.zig
error(x86_64_encoder): no encoding found for: none mov r64 m128 none none
main.zig:1:8: error: emit MIR failed: InvalidInstruction (Zig compiler bug)
export fn repro(bytes: *[0]u8) void {
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
The size of bytes
doesn't matter, it occurs for any pointer to a runtime-known array, specifically the pointee (i.e. even for a comptime-known pointer to a runtime-known array, for example, pointer to a global var).
It appears related specifically to concatenation of a pointer to a runtime-known array with a slice, concatenating with a comptime-known array pointer does not reproduce this error - removing the @as
above actually compiles, even for non-zero sized bytes.*
, strangely enough.
Expected Behavior
Same behavior as concatenating an array pointer, which I would expect to be a compile error about being unable to concatenate using a pointer to a runtime-known value, but currently appears to construct a new pointer to a runtime-known value on the stack.