After asking this question about interface fields in records I assumed that the following would work (notice the assertion):

type
  TRec <T> = record
    Intf : IInterface;
  end;

  TTestClass = class
  public
    function ReturnRec : TRec <Integer>;
  end;

  // Implementation 
  function TTestClass.ReturnRec : TRec <Integer>;
  begin
    Assert (Result.Intf = nil);    // Interface field in record should be initialized!
    Result.Intf := TInterfacedObject.Create;
  end;

I tested this with the following code:

  for I := 1 to 1000 do
    Rec := Test.ReturnRec;

and the assertion fails!

Where's my mistake here? What assumption is wrong?

Edit
Report