[fpc-pascal] Segmentation fault gone if compiled with -glh

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Jan 10 16:10:04 CET 2011


On 10 Jan 2011, at 06:54, Jeppe Johansen wrote:

> Doesn't the problem lie in that TFPGObjectList uses @ on the  
> incoming parameters?
>
> function TFPGObjectList.Add(const Item: T): Integer;
> begin
>  Result := inherited Add(@Item);
> end;
>
> Unless there's some magic going on, won't it then point to the  
> stack, instead of the instance, in most cases?

Maybe it should use "constref" instead of "const". There's indeed no  
guarantee whatsoever that a "const" parameter will be passed by  
reference, and hence @item will indeed result in a stack address in  
many cases.


Jonas



More information about the fpc-pascal mailing list