Skip to content

error(x86_67_encoder): no encoding found for: none mov r64 m128 none none #24953

Description

@InKryption

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.

Activity

  1. added
    bugObserved behavior contradicts documented or intended behavior
    on Aug 22, 2025
  2. jacobly0 commented on Aug 26, 2025

    @jacobly0
    Member

    Invalid AIR, source is never allowed to be a slice:

    %8!= memcpy(%7!, <[]const u8, &.{}[0..0]>)
    

    Also length is never allowed to be comptime-known 0.

  3. added this to the urgent milestone on Aug 26, 2025
  4. added
    frontendTokenization, parsing, AstGen, Sema, and Liveness.
    on Aug 26, 2025
  5. self-assigned this
    on Aug 27, 2025
  6. modified the milestones: urgent, 0.16.0 on Oct 11, 2025
  7. mlugg commented on Mar 19, 2026

    @mlugg
    Member

    Oh, looks like this is already fixed on master:

    $ zig build-obj repro.zig
    $ zig build-obj repro.zig --verbose-air
    # Begin Function AIR: repro.repro:
    # Total AIR+Liveness bytes: 237B
    # AIR Instructions:         9 (81B)
    # AIR Extra Data:           9 (36B)
    # Liveness tomb_bits:       8B
    # Liveness Extra Data:      0 (0B)
    # Liveness special table:   0 (0B)
      %0!= arg(*[0]u8, 0)
      %1!= save_err_return_trace_index()
      %2!= dbg_stmt(2:5)
      %5!= alloc(*[0]u8)
      %6!= bitcast([*]u8, %5)
      %7!= bitcast(*const [0]u8, %5)
      %8!= ret_safe(@.void_value)
    # End Function AIR: repro.repro
    $

    Builds correctly, and the bad AIR instruction is gone. I think I fixed this in my big type resolution diff---I do recall having to fix some AIR memcpys.

    Closing as solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions