anchor.diff:          Inc(arg_ptr,sizeof(Pointer));
         end
         else
  -        case arg_type of
  -          varError:
  -            arg_data^.vError:=VAR_PARAMNOTFOUND;
  -          varVariant:
  -            begin
  +        begin
  +          arg_advanced:=false;
  +          case arg_type of
  +            varError:
  +              begin
  +                arg_data^.vError:=VAR_PARAMNOTFOUND;
  +                arg_advanced := true;
  +              end;
  +            varVariant:
                 arg_data^ := PVarData(PPointer(arg_ptr)^)^;
  -              Inc(arg_ptr,sizeof(Pointer));
  -            end;
  -          varDouble, varCurrency, varInt64, varQWord, varDate:
  -            begin
  -              arg_data^.vQWord := PQWord(arg_ptr)^; // 64bit on all platforms
  -              inc(arg_ptr,sizeof(qword))
  -            end
  -        else
  -          arg_data^.vAny := PPointer(arg_ptr)^; // 32 or 64bit
  -          inc(arg_ptr,sizeof(pointer))
  +            varDouble, varCurrency, varDate, varInt64, varQWord:
  +              begin
  +                arg_data^.vQWord := PQWord(arg_ptr)^; // 64bit on all platforms
  +                inc(arg_ptr,sizeof(QWord));
  +                arg_advanced := true;
  +              end;
  +            { values potentially smaller than sizeof(pointer) must be handled
  +              explicitly to guarantee endian safety and to prevent copying/
  +              skipping data (they are always copied into a 4 byte element
  +              by the compiler, although it will still skip sizeof(pointer)
  +              bytes afterwards) }
  +            varSingle:
  +              arg_data^.vSingle := PSingle(arg_ptr)^;
  +            varSmallint:
  +              arg_data^.vSmallInt := PLongint(arg_ptr)^;
  +            varInteger:
  +              arg_data^.vInteger := PLongint(arg_ptr)^;
  +            varBoolean:
  +              arg_data^.vBoolean := WordBool(PLongint(arg_ptr)^);
  +            varShortInt:
  +              arg_data^.vShortInt := PLongint(arg_ptr)^;
  +            varByte:
  +              arg_data^.vByte := PLongint(arg_ptr)^;
  +            varWord:
  +              arg_data^.vWord := PLongint(arg_ptr)^;
  +            else
  +              arg_data^.vAny := PPointer(arg_ptr)^; // 32 or 64bit
  +          end;
  +          if not arg_advanced then
  +            inc(arg_ptr,sizeof(pointer));
           end;
       end;
     end;
  
positive.code:  *                                                        *
   * hprose common unit for delphi.                         *
   *                                                        *
   * LastModified: Sep 13, 2014                             *
   * Author: Ma Bingyao <andot@hprose.com>                  *
   *                                                        *
  \**********************************************************/
  
negative.code: 
    TVarObjectType = class(TInvokeableVariantType, IVarInstanceReference)
    protected
  {$IF DEFINED(FPC) AND (FPC_VERSION < 3)}
      procedure DispInvoke(Dest: PVarData; const Source: TVarData;
        CallDesc: PCallDesc; Params: Pointer); override;
  {$IFEND}
      { IVarInstanceReference }
      function GetInstance(const V: TVarData): TObject;
    public
  