On 29 May 2010, at 12:56, Frank Peelo wrote:

> On 27/05/10 23:13, Jonas Maebe wrote:
>> On 27 May 2010, at 23:31, Yann Bat wrote:
>>   
>>>> The compiler always adds a VMT if an object has a constructor or 
>>>> destructor. The reason is that the VMT also contains the instance size, 
>>>> which is used by the constructor helper to allocate the required amount of 
>>>> memory.
>>>>       
>>> Ok but why a different behaviour between [fpc | objfpc] mode and [tp |
>>> delphi] mode ?
>>>     
>> It is allowed in Delphi and TP because they allow declaring typed constants 
>> of objects. I don't remember why it was disabled in the FPC modes, but that 
>> happened a long time ago (before the move from cvs to svn). Maybe someone 
>> else does.
> 
> Definitely TP-style objects did not have a VMT unless you declared a virtual 
> method, in TP. And a destructor was only virtual if it was declared virtual. 
> Hence typed constant objects could be possible.

I made a typo in the comment above (my first quoted statement at the top of the 
mail is still correct though), it should have read "It is allowed in Delphi and 
TP because they allow declaring typed constants of objects *that contain a 
VMT*". As I explained, FPC adds a VMT for any object type that contains a 
constructor or destructor. This by itself may be another incompatibility with 
TP/Delphi.

> Presumably FPC decided compatibility with this feature was not desirable?

The reason for adding the VMT as soon as there is a constructor or destructor 
may be for implementation reasons, although it's strange that this is 
TP-incompatible since this was probably implemented by Pierre or Carl-Eric, and 
they generally paid a lot of attention to being binary compatible to TP as much 
as possible.

As mentioned before, I don't know the reason for not allowing typed constants 
of TP-style objects that have a 
VMT._______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to