]> git.lizzy.rs Git - rust.git/commitdiff
Fix GEPs for MIR indexing translation
authorSimonas Kazlauskas <git@kazlauskas.me>
Sat, 19 Dec 2015 18:28:12 +0000 (20:28 +0200)
committerSimonas Kazlauskas <git@kazlauskas.me>
Sat, 19 Dec 2015 18:30:13 +0000 (20:30 +0200)
Fixes #30474

src/librustc_trans/trans/mir/lvalue.rs

index f3c2c3459796ac634f5e71418d20e664bccf1781..b167633909a4a3bde6f5d02ddf6e22cefd8113cd 100644 (file)
@@ -132,7 +132,8 @@ pub fn trans_lvalue(&mut self,
                     mir::ProjectionElem::Index(ref index) => {
                         let index = self.trans_operand(bcx, index);
                         let llindex = self.prepare_index(bcx, index.immediate());
-                        (build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
+                        let zero = common::C_uint(bcx.ccx(), 0u64);
+                        (build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
                          ptr::null_mut())
                     }
                     mir::ProjectionElem::ConstantIndex { offset,
@@ -140,7 +141,8 @@ pub fn trans_lvalue(&mut self,
                                                          min_length: _ } => {
                         let lloffset = common::C_u32(bcx.ccx(), offset);
                         let llindex = self.prepare_index(bcx, lloffset);
-                        (build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
+                        let zero = common::C_uint(bcx.ccx(), 0u64);
+                        (build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
                          ptr::null_mut())
                     }
                     mir::ProjectionElem::ConstantIndex { offset,
@@ -150,7 +152,8 @@ pub fn trans_lvalue(&mut self,
                         let lllen = self.lvalue_len(bcx, tr_base);
                         let llindex = build::Sub(bcx, lllen, lloffset, DebugLoc::None);
                         let llindex = self.prepare_index(bcx, llindex);
-                        (build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
+                        let zero = common::C_uint(bcx.ccx(), 0u64);
+                        (build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
                          ptr::null_mut())
                     }
                     mir::ProjectionElem::Downcast(..) => {