@@ -2317,13 +2317,11 @@ std::optional<Pointer> OffsetHelper(InterpState &S, CodePtr OpPC,
23172317template <PrimType Name, class T = typename PrimConv<Name>::T>
23182318bool AddOffset (InterpState &S, CodePtr OpPC) {
23192319 const T &Offset = S.Stk .pop <T>();
2320- Pointer Ptr = S.Stk .pop <Pointer>();
2321- if (Ptr.isBlockPointer ())
2322- Ptr = Ptr.expand ();
2320+ const Pointer &Ptr = S.Stk .pop <Pointer>().expand ();
23232321
23242322 if (std::optional<Pointer> Result = OffsetHelper<T, ArithOp::Add>(
23252323 S, OpPC, Offset, Ptr, /* IsPointerArith=*/ true )) {
2326- S.Stk .push <Pointer>(* Result);
2324+ S.Stk .push <Pointer>(Result-> narrow () );
23272325 return true ;
23282326 }
23292327 return false ;
@@ -2332,11 +2330,11 @@ bool AddOffset(InterpState &S, CodePtr OpPC) {
23322330template <PrimType Name, class T = typename PrimConv<Name>::T>
23332331bool SubOffset (InterpState &S, CodePtr OpPC) {
23342332 const T &Offset = S.Stk .pop <T>();
2335- const Pointer &Ptr = S.Stk .pop <Pointer>();
2333+ const Pointer &Ptr = S.Stk .pop <Pointer>(). expand () ;
23362334
23372335 if (std::optional<Pointer> Result = OffsetHelper<T, ArithOp::Sub>(
23382336 S, OpPC, Offset, Ptr, /* IsPointerArith=*/ true )) {
2339- S.Stk .push <Pointer>(* Result);
2337+ S.Stk .push <Pointer>(Result-> narrow () );
23402338 return true ;
23412339 }
23422340 return false ;
@@ -2362,7 +2360,7 @@ static inline bool IncDecPtrHelper(InterpState &S, CodePtr OpPC,
23622360 if (std::optional<Pointer> Result =
23632361 OffsetHelper<OneT, Op>(S, OpPC, One, P, /* IsPointerArith=*/ true )) {
23642362 // Store the new value.
2365- Ptr.deref <Pointer>() = * Result;
2363+ Ptr.deref <Pointer>() = Result-> narrow () ;
23662364 return true ;
23672365 }
23682366 return false ;
@@ -2391,8 +2389,8 @@ static inline bool DecPtr(InterpState &S, CodePtr OpPC) {
23912389// / 3) Pushes the difference of the indices of the two pointers on the stack.
23922390template <PrimType Name, class T = typename PrimConv<Name>::T>
23932391inline bool SubPtr (InterpState &S, CodePtr OpPC, bool ElemSizeIsZero) {
2394- const Pointer &LHS = S.Stk .pop <Pointer>();
2395- const Pointer &RHS = S.Stk .pop <Pointer>();
2392+ const Pointer &LHS = S.Stk .pop <Pointer>(). expand () ;
2393+ const Pointer &RHS = S.Stk .pop <Pointer>(). expand () ;
23962394
23972395 if (!Pointer::hasSameBase (LHS, RHS) && S.getLangOpts ().CPlusPlus ) {
23982396 S.FFDiag (S.Current ->getSource (OpPC),
@@ -3083,7 +3081,7 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
30833081 S.Stk .push <Pointer>(Ptr.atIndex (0 ).narrow ());
30843082 return true ;
30853083 }
3086- S.Stk .push <Pointer>(Ptr);
3084+ S.Stk .push <Pointer>(Ptr. narrow () );
30873085 return true ;
30883086 }
30893087
@@ -3114,7 +3112,7 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
31143112 S.Stk .push <Pointer>(Ptr.atIndex (0 ).narrow ());
31153113 return true ;
31163114 }
3117- S.Stk .push <Pointer>(Ptr);
3115+ S.Stk .push <Pointer>(Ptr. narrow () );
31183116 return true ;
31193117 }
31203118
@@ -3189,7 +3187,7 @@ inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
31893187 }
31903188
31913189 if (Ptr.isRoot () || !Ptr.isUnknownSizeArray ()) {
3192- S.Stk .push <Pointer>(Ptr.atIndex (0 ));
3190+ S.Stk .push <Pointer>(Ptr.atIndex (0 ). narrow () );
31933191 return true ;
31943192 }
31953193
0 commit comments