[fpc-pascal] Using Supports() I got an AV... bug?

Vojtěch Čihák vojtech.cihak at atlas.cz
Sun Mar 11 19:16:12 CET 2018


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" <md at delfire.net>
> Komu: FPC-Pascal users discussions <fpc-pascal at 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.cihak at 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 at lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180311/be8987e5/attachment.html>


More information about the fpc-pascal mailing list