Open
Description
This code causes libgccjit errors:
#[derive(Copy, Clone,Default)]
#[repr(C)]
struct Many3 {
f0: u64,
f1: u64,
f2: u8,
}
extern "C" fn struct_in_3(_: Many3){}
#[no_mangle]
fn do_test() {
struct_in_3(Many3::default());
}
The repr(C)
on the struct is not needed, but it sliences the imporper-ctype warning.
error:
libgccjit.so: error: : bitcast with types of different sizes
input expression (size: 64):
<addr_expr 0x7efdb68e95c0
type <pointer_type 0x7efdb68f29d8
type <array_type 0x7efdb68f2930 type <integer_type 0x7efdb68ecc78 signed char>
BLK
size <integer_cst 0x7efdb6b60690 constant 192>
unit-size <integer_cst 0x7efdb6b606c0 constant 24>
user align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7efdb68f2888 domain <integer_type 0x7efdb68f2738>
pointer_to_this <pointer_type 0x7efdb68f29d8>>
unsigned DI
size <integer_cst 0x7efdb6b60228 constant 64>
unit-size <integer_cst 0x7efdb6b60240 constant 8>
align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7efdb68f2a80>
visited
arg:0 <var_decl 0x7efdb68f8000 stack_var_1 type <array_type 0x7efdb68f2930>
addressable visited BLK (null):0:0 size <integer_cst 0x7efdb6b60690 192> unit-size <integer_cst 0x7efdb6b606c0 24>
align:64 warn_if_not_align:0 context <function_decl 0x7efdb68f4200 do_test>>>
requested type (size: 192):
<record_type 0x7efdb68eca80 BLK
size <integer_cst 0x7efdb6b60690 type <integer_type 0x7efdb6b4b690 bitsizetype> constant 192>
unit-size <integer_cst 0x7efdb6b606c0 type <integer_type 0x7efdb6b4b5e8 sizetype> constant 24>
user align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7efdb68eca80
fields <field_decl 0x7efdb68f15a0 field_0
type <array_type 0x7efdb68f2000 type <integer_type 0x7efdb68ece70 long int>
BLK
size <integer_cst 0x7efdb6b602a0 constant 0>
unit-size <integer_cst 0x7efdb6b60258 constant 0>
user align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7efdb68f20a8 domain <integer_type 0x7efdb68ec9d8>>
BLK (null):0:0 size <integer_cst 0x7efdb6b602a0 0> unit-size <integer_cst 0x7efdb6b60258 0>
user align:64 warn_if_not_align:0 offset_align 256 decl_not_flexarray: 0 offset <integer_cst 0x7efdb6b60258 0> bit-offset <integer_cst 0x7efdb6b602a0 0> context <record_type 0x7efdb68eca80 >
chain <field_decl 0x7efdb68f1640 field_1 type <integer_type 0x7efdb68ec7e0 size_t>
unsigned DI (null):0:0
size <integer_cst 0x7efdb6b60228 constant 64>
unit-size <integer_cst 0x7efdb6b60240 constant 8>
user align:64 warn_if_not_align:0 offset_align 256 decl_not_flexarray: 0 offset <integer_cst 0x7efdb6b60258 0> bit-offset <integer_cst 0x7efdb6b602a0 0> context <record_type 0x7efdb68eca80 > chain <field_decl 0x7efdb68f16e0 field_2>>>
pointer_to_this <pointer_type 0x7efdb68f2690>>
error: could not copy "/app/output.example.f9d5a4a502c358ed-cgu.0.rcgu.s" to "/app/output.s": No such file or directory (os error 2)
error: aborting due to 1 previous error
Compiler returned: 1
Since the bitcast input is 64 bits in size(pointer on x86_64), and the output has the same size as the structure in question, it looks like we are bitcasting the pointer to a structure instead of the structure itself.