Open
Description
Currently, attempting to bitcast a type of incorrect size will lead to an internal libgccjit error, and a crash.
libgccjit.so: error: : bitcast with types of different sizes
input expression (size: 64):
This is suboptimal, because this error misses information crucial for debugging, such as the backtrace pointing to the source of the error.
We could add an assertion that checks for this error:
#[cfg(debug_assertions)]
{
let rvalue_size = rvalue.get_type().get_size();
let dest_size = dest_type.get_size();
assert_eq!(
rvalue_size,
dest_size,
"Mismatching bitcast. rvalue_size != dest_size.\nrvalue:{rvalue:?}\ndest_type:{dest_type:?}"
);
}
Sadly, due to the unreliable nature of get_size
, this is not possible: that function will panic when attempting to retrive the size of types such as bool
.
If get_size
returned an Option
/Result
(or a function like get_size_checked
existed), we could skip this sanity check in such a case.