Skip to content

Commit c6079d0

Browse files
committed
Auto merge of #30486 - nagisa:mir-fix-geps, r=luqmana
Fixes #30474
2 parents 2b8e96d + 2b2f983 commit c6079d0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/librustc_trans/trans/mir/lvalue.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,17 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
132132
mir::ProjectionElem::Index(ref index) => {
133133
let index = self.trans_operand(bcx, index);
134134
let llindex = self.prepare_index(bcx, index.immediate());
135-
(build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
135+
let zero = common::C_uint(bcx.ccx(), 0u64);
136+
(build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
136137
ptr::null_mut())
137138
}
138139
mir::ProjectionElem::ConstantIndex { offset,
139140
from_end: false,
140141
min_length: _ } => {
141142
let lloffset = common::C_u32(bcx.ccx(), offset);
142143
let llindex = self.prepare_index(bcx, lloffset);
143-
(build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
144+
let zero = common::C_uint(bcx.ccx(), 0u64);
145+
(build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
144146
ptr::null_mut())
145147
}
146148
mir::ProjectionElem::ConstantIndex { offset,
@@ -150,7 +152,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
150152
let lllen = self.lvalue_len(bcx, tr_base);
151153
let llindex = build::Sub(bcx, lllen, lloffset, DebugLoc::None);
152154
let llindex = self.prepare_index(bcx, llindex);
153-
(build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
155+
let zero = common::C_uint(bcx.ccx(), 0u64);
156+
(build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
154157
ptr::null_mut())
155158
}
156159
mir::ProjectionElem::Downcast(..) => {

0 commit comments

Comments
 (0)