@@ -1249,6 +1249,7 @@ protected internal override TranslatedExpression VisitBinaryNumericInstruction(B
12491249 {
12501250 return null ;
12511251 }
1252+ TranslatedExpression ? offsetExpressionFromTypeHint = null ;
12521253 if ( context . TypeHint . Kind == TypeKind . Pointer )
12531254 {
12541255 // We use the type hint if one of the following is true:
@@ -1258,13 +1259,17 @@ protected internal override TranslatedExpression VisitBinaryNumericInstruction(B
12581259
12591260 var typeHint = ( PointerType ) context . TypeHint ;
12601261 int elementTypeSize = pointerType . ElementType . GetSize ( ) ;
1261- if ( ( elementTypeSize == 0 || typeHint . ElementType . GetSize ( ) != elementTypeSize )
1262- && GetPointerArithmeticOffset ( byteOffsetInst , byteOffsetExpr , typeHint . ElementType , inst . CheckForOverflow ) != null )
1262+ if ( elementTypeSize == 0 || typeHint . ElementType . GetSize ( ) != elementTypeSize )
12631263 {
1264- pointerType = typeHint ;
1264+ offsetExpressionFromTypeHint = GetPointerArithmeticOffset ( byteOffsetInst , byteOffsetExpr , typeHint . ElementType , inst . CheckForOverflow ) ;
1265+ if ( offsetExpressionFromTypeHint != null )
1266+ {
1267+ pointerType = typeHint ;
1268+ }
12651269 }
12661270 }
1267- TranslatedExpression offsetExpr = GetPointerArithmeticOffset ( byteOffsetInst , byteOffsetExpr , pointerType . ElementType , inst . CheckForOverflow )
1271+ TranslatedExpression offsetExpr = offsetExpressionFromTypeHint
1272+ ?? GetPointerArithmeticOffset ( byteOffsetInst , byteOffsetExpr , pointerType . ElementType , inst . CheckForOverflow )
12681273 ?? FallBackToBytePointer ( ) ;
12691274
12701275 if ( left . Type . Kind == TypeKind . Pointer )
0 commit comments