Skip to content

Commit

Permalink
Fix gep on pointers to non-number
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Sep 20, 2023
1 parent f3b82df commit 03020c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
// require dereferencing the pointer.
for index in indices {
pointee_type = pointee_type.get_pointee().expect("pointee type");
let pointee_size = self.context.new_rvalue_from_int(index.get_type(), pointee_type.get_size() as i32);
let size = self.cx.context.new_sizeof(pointee_type);
let pointee_size = self.context.new_cast(None, size, index.get_type());
result = result + self.gcc_int_cast(*index * pointee_size, self.sizet_type);
}
self.context.new_bitcast(None, result, ptr_type)
Expand Down

0 comments on commit 03020c4

Please sign in to comment.