I only added {$mode objfpc} to be able compile, so I test this code:
 
program Project1;
{$mode objfpc}
 
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
    //FreeAndNil(Bar);
  end;
 
end.           
 
My FPC is also 3.0.4, on 64-bit Linux.
Compiled with -gh I have no memory leak since this demo is about COM interfaces.
 
V.
______________________________________________________________
Od: "Marcos Douglas B. Santos" <m...@delfire.net>
Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Datum: 11.03.2018 16:17
Předmět: Re: [fpc-pascal] Using Supports() I got an AV... bug?

On Sun, Mar 11, 2018 at 11:51 AM, Vojtěch Čihák <vojtech.ci...@atlas.cz> wrote:
> With this modification and -gh it is alright:
>

Only if you declare `Bar` as `IBar` instead of `TBar`. Please, check
your code again.

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

Reply via email to