Skip to content

ICE bitcast with types of different sizes with #[repr(align))] #829

@matthiaskrgr

Description

@matthiaskrgr
#[repr(align(64))]
#[derive(Default)]
struct AlignedF32(f32);
extern fn write<T>(x : T, dest : &T) {}
fn check<T : Default>(x : T) {
  let out = T::default();
  write(x, &out)
}
fn main() { check(AlignedF32(6.0)) }
warning: `extern` declarations without an explicit ABI are deprecated
 --> code.rs:4:1
  |
4 | extern fn write<T>(x : T, dest : &T) {}
  | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
  |
  = note: `#[warn(missing_abi)]` on by default

warning: unused variable: `x`
 --> code.rs:4:20
  |
4 | extern fn write<T>(x : T, dest : &T) {}
  |                    ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: unused variable: `dest`
 --> code.rs:4:27
  |
4 | extern fn write<T>(x : T, dest : &T) {}
  |                           ^^^^ help: if this is intentional, prefix it with an underscore: `_dest`

warning: field `0` is never read
 --> code.rs:3:19
  |
3 | struct AlignedF32(f32);
  |        ---------- ^^^
  |        |
  |        field in this struct
  |
  = help: consider removing this field
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

libgccjit.so: error: : bitcast with types of different sizes
input expression (size: 64):
 <addr_expr 0x7fbcf2739a60
    type <pointer_type 0x7fbcf27477e0
        type <array_type 0x7fbcf2747738 type <integer_type 0x7fbcfb9a41f8 signed char>
            BLK
            size <integer_cst 0x7fbcfb9b8420 constant 512>
            unit-size <integer_cst 0x7fbcfb9b8c18 constant 64>
            user align:512 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fbcf2747348 domain <integer_type 0x7fbcf27472a0>
            pointer_to_this <pointer_type 0x7fbcf27477e0>>
        unsigned DI
        size <integer_cst 0x7fbcfb9b8000 constant 64>
        unit-size <integer_cst 0x7fbcfb9b8018 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fbcf2747540>
    visited
    arg:0 <var_decl 0x7fbcf2754098 stack_var_2 type <array_type 0x7fbcf2747738>
        addressable visited BLK (null):0:0 size <integer_cst 0x7fbcfb9b8420 512> unit-size <integer_cst 0x7fbcfb9b8c18 64>
        align:512 warn_if_not_align:0 context <function_decl 0x7fbcf2744700 _RINvCs5RvIIZZzctW_4code5checkNtB2_10AlignedF32EB2_>
        chain <var_decl 0x7fbcf2754000 stack_var_1 type <array_type 0x7fbcf27473f0>
            addressable visited BLK (null):0:0 size <integer_cst 0x7fbcfb9b8420 512> unit-size <integer_cst 0x7fbcfb9b8c18 64>
            align:512 warn_if_not_align:0 context <function_decl 0x7fbcf2744700 _RINvCs5RvIIZZzctW_4code5checkNtB2_10AlignedF32EB2_>>>>
requested type (size: 512):
 <record_type 0x7fbcf2743f18  BLK
    size <integer_cst 0x7fbcfb9b8420 type <integer_type 0x7fbcfb9a4000 bitsizetype> constant 512>
    unit-size <integer_cst 0x7fbcfb9b8c18 type <integer_type 0x7fbcfb9a4f18 sizetype> constant 64>
    user align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fbcf2743f18
    fields <field_decl 0x7fbcf27463c0 field_0
        type <array_type 0x7fbcf27433f0 type <integer_type 0x7fbcf27439d8 int>
            BLK
            size <integer_cst 0x7fbcfb9b8078 constant 0>
            unit-size <integer_cst 0x7fbcfb9b8030 constant 0>
            user align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fbcf2743498 domain <integer_type 0x7fbcf2743348>>
        BLK (null):0:0 size <integer_cst 0x7fbcfb9b8078 0> unit-size <integer_cst 0x7fbcfb9b8030 0>
        user align:32 warn_if_not_align:0 offset_align 256 decl_not_flexarray: 0 offset <integer_cst 0x7fbcfb9b8030 0> bit-offset <integer_cst 0x7fbcfb9b8078 0> context <record_type 0x7fbcf2743f18 >
        chain <field_decl 0x7fbcf2746460 field_1 type <real_type 0x7fbcfb9be888>
            SF (null):0:0
            size <integer_cst 0x7fbcfb9b8240 constant 32>
            unit-size <integer_cst 0x7fbcfb9b8258 constant 4>
            align:32 warn_if_not_align:0 offset_align 256 decl_not_flexarray: 0 offset <integer_cst 0x7fbcfb9b8030 0> bit-offset <integer_cst 0x7fbcfb9b8078 0> context <record_type 0x7fbcf2743f18 > chain <field_decl 0x7fbcf2746500 field_2>>>
    pointer_to_this <pointer_type 0x7fbcf2743738>>
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/home/matthias/vcs/github/CRED/rustcHOrh7n/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" "/home/matthias/vcs/github/CRED/rustcHOrh7n/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" "code" "-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 code.code.444a81fd07d3598a-cgu.0.rcgu.o: No such file or directory
          collect2: error: ld returned 1 exit status


error: aborting due to 1 previous error; 4 warnings emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions