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

Jeppe Johansen jepjoh2 at es.aau.dk
Mon Jan 10 16:20:26 CET 2011


Den 10-01-2011 16:10, Jonas Maebe skrev:
>
> 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
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Ah yes. Michael is correct. TFPSList copies FItemSize bytes from that 
pointer. But it would probably be a very good idea to use constref 
instead of const anyway



More information about the fpc-pascal mailing list