diff --git a/compiler/ncginl.pas b/compiler/ncginl.pas
index e920d0492f..ab0887dc00 100644
--- a/compiler/ncginl.pas
+++ b/compiler/ncginl.pas
@@ -252,7 +252,7 @@ implementation
          hregister : tregister;
       begin
         if inlinenumber=in_sizeof_x then
-          location_reset(location,LOC_REGISTER,OS_INT)
+          location_reset(location,LOC_REGISTER,def_cgsize(resultdef))
         else
           location_reset(location,LOC_REGISTER,OS_ADDR);
         { for both cases load vmt }
@@ -355,7 +355,7 @@ implementation
            if is_widestring(left.resultdef) then
              cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SHR,OS_INT,1,hregister);
            cg.a_label(current_asmdata.CurrAsmList,lengthlab);
-           location_reset(location,LOC_REGISTER,OS_INT);
+           location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
            location.register:=hregister;
          end;
       end;
diff --git a/compiler/x86_64/nx64add.pas b/compiler/x86_64/nx64add.pas
index 79ad59e7ab..4b744bc0fa 100644
--- a/compiler/x86_64/nx64add.pas
+++ b/compiler/x86_64/nx64add.pas
@@ -38,6 +38,7 @@ interface
     uses
       globtype,globals,
       aasmbase,aasmtai,aasmdata,
+      defutil,
       cgbase,cgutils,cga,cgobj,
       tgobj;
 
@@ -56,7 +57,7 @@ interface
       pass_left_right;
 
       { The location.register will be filled in later (JM) }
-      location_reset(location,LOC_REGISTER,OS_INT);
+      location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
       { Mul supports registers and references, so if not register/reference,
         load the location into a register}
       use_ref:=false;