<p style="padding:0 0 0 0; margin:0 0 0 0;">I only added {$mode objfpc} to be able compile, so I test this code:</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">program Project1;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">{$mode objfpc}</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">uses</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> SysUtils;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">type</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> IBar = interface</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> ['{C22FB8F4-1EC6-42C4-81E4-F2A52CC52258}']</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> function Name: string;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> TBar = class(TInterfacedObject, IBar)</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> public</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> function Name: string;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">{ TBar }</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">function TBar.Name: string;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">begin</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> Result := ClassName;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">var</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> Bar: TBar;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">begin</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> Bar := TBar.Create;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> try</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> if Supports(Bar, IBar) then</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> Writeln('Bar supports...');</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> finally</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> //FreeAndNil(Bar);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">end. </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">My FPC is also 3.0.4, on 64-bit Linux.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">Compiled with -gh I have no memory leak since this demo is about COM interfaces.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">V.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">______________________________________________________________<br />
> Od: "Marcos Douglas B. Santos" <md@delfire.net><br />
> Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org><br />
> Datum: 11.03.2018 16:17<br />
> Předmět: Re: [fpc-pascal] Using Supports() I got an AV... bug?<br />
></p>
On Sun, Mar 11, 2018 at 11:51 AM, Vojtěch Čihák <vojtech.cihak@atlas.cz> wrote:<br />
> With this modification and -gh it is alright:<br />
><br />
<br />
Only if you declare `Bar` as `IBar` instead of `TBar`. Please, check<br />
your code again.<br />
<br />
Regards,<br />
Marcos Douglas<br />
_______________________________________________<br />
fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br />
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>