extern crate llvm;
use llvm::*;
fn main() {
let context = Context::new();
let module = Module::new("test", &context);
let u8_type = Type::get::<u8>(&context);
let array_type = ArrayType::new(u8_type, 32);
let struct_type = StructType::new(
&context,
&[
array_type,
],
false);
let struct_ptr_type = PointerType::new(struct_type);
let void_type = Type::get::<()>(&context);
let fn_type = FunctionType::new(
void_type,
&[struct_ptr_type]);
let func = module.add_function("test_func", fn_type);
let first_block = func.append("a_block");
let builder = Builder::new(&context);
builder.position_at_end(first_block);
let arg_ptr = &func[0];
let zero = 0usize.compile(&context);
builder.build_gep(arg_ptr, &[zero, zero]);
}
crashing code:
if I change 0usize to 0u32 then it doesn't crash.