The code below should work but I get an AV when the program calls
`Bar.Free`.

Do you know why?

Lazarus 1.8.1 r57299 FPC 3.0.4 i386-win32-win32/win64

===begin===
program Project1;

uses
  SysUtils;

type
  IBar = interface
  ['{C22FB8F4-1EC6-42C4-81E4-F2A52CC52258}']
    function Name: string;
  end;

  TBar = class(TInterfacedObject, IBar)
  public
    function Name: string;
  end;

{ TBar }

function TBar.Name: string;
begin
  Result := ClassName;
end;

var
  Bar: TBar;

begin
  Bar := TBar.Create;
  try
    if Supports(Bar, IBar) then
      Writeln('Bar supports...');
  finally
    Bar.Free;
  end;

end.
===end===

Regards,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to