[fpc-pascal] FPC bug or brain bug ?
XHajT03 at hajny.biz
Sat May 29 13:22:30 CEST 2010
On Sat, May 29, 2010 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.
> Presumably FPC decided compatibility with this feature was not desirable?
I believe the same is the case with FPC and _objects_ (not classes) and
FPC is thus compatible here. The text above (mentioning constructors
allocating the memory) probably refers to classes. In case of objects,
constructor does not need to allocate memory because the object is either
declared statically, or it's declared dynamically, but the allocation
happens before the constructor is invoked.
More information about the fpc-pascal