From 03020c417d570c9e4af81cce2bca392488358dac Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 19 Sep 2023 22:20:35 -0400 Subject: [PATCH] Fix gep on pointers to non-number --- Cargo.lock | 4 ++-- src/builder.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 404fb9c6db1..85675fc40c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,7 +74,7 @@ dependencies = [ [[package]] name = "gccjit" version = "1.0.0" -source = "git+https://github.com/antoyo/gccjit.rs#ff1f82584c760a8b870dc6bad9841bd090f92f80" +source = "git+https://github.com/antoyo/gccjit.rs#0b158c68bf7e46732869d90550a98e886dee8858" dependencies = [ "gccjit_sys", ] @@ -82,7 +82,7 @@ dependencies = [ [[package]] name = "gccjit_sys" version = "0.0.1" -source = "git+https://github.com/antoyo/gccjit.rs#ff1f82584c760a8b870dc6bad9841bd090f92f80" +source = "git+https://github.com/antoyo/gccjit.rs#0b158c68bf7e46732869d90550a98e886dee8858" dependencies = [ "libc", ] diff --git a/src/builder.rs b/src/builder.rs index b0feb99e3c6..e6dd19e4adc 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -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)