Skip to content

ICE gcc_jit_block_add_assignment: mismatching types: assignment to input_register #830

Closed

Description

@matthiaskrgr

snippet:

//@compile-flags: -Zcodegen-backend=gcc
unsafe fn a() {
    let j = {};
    let pointer = &j;
    core::arch::asm !("", in("eax")pointer)
}

fn main() {
    unsafe { a() }
}

Version information

rustc 1.95.0-nightly (87b272187 2026-01-24)
binary: rustc
commit-hash: 87b272187129343c0efc8f92d253c16958aeac0b
commit-date: 2026-01-24
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=gcc

Program output

libgccjit.so: error: : gcc_jit_block_add_assignment: mismatching types: assignment to input_register (type: __int8_t *) from &stack_var_1 (type: __int8_t[0]  __attribute__((aligned(1))) *)
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/tmp/icemaker_global_tempdir.SlDjrMXGPvw1/rustc_testrunner_tmpdir_reporting.onHHy0kZiHXB/rustcbLsks4/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/icemaker_global_tempdir.SlDjrMXGPvw1/rustc_testrunner_tmpdir_reporting.onHHy0kZiHXB/rustcbLsks4/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "outputfile" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: cannot open outputfile.mvce.d7c3bcf1ed0de24f-cgu.0.rcgu.o: No such file or directory
          collect2: error: ld returned 1 exit status
          

error: aborting due to 1 previous error


Activity

  1. Dnreikronos commented on May 30, 2026

    @Dnreikronos
    Contributor

    This looks already fixed by #874 (commit 6ecabe8), which landed on master on April 30.

    I reproduced it locally to confirm. If I revert that commit's change and rebuild the backend, the exact error from this report comes back:

    gcc_jit_block_add_assignment: mismatching types: assignment to input_register (type: __int8_t *) from &stack_var_1 (type: __int8_t[0]  __attribute__((aligned(1))) *)
    

    With the fix in place the snippet compiles fine. The change casts the input value to the register type before the assignment when the two differ, which covers the &() case where the pointer is typed as a pointer to a zero-length array.

    Probably safe to close.

    cc// @antoyo and @matthiaskrgr

  2. antoyo commented on May 31, 2026

    @antoyo
    Contributor

    Fixed by #874.

    Indeed, thanks for pointing that out.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions