[fpc-pascal] FPC bug or brain bug ?
jonas.maebe at elis.ugent.be
Sat May 29 15:51:35 CEST 2010
On 29 May 2010, at 13:22, Tomas Hajny wrote:
> 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.
Semantically, yes. Implementation-wise, no:
#  new(o,init);
The first $0 parameter (in %eax) indicates that memory still has to be reserved. P$PROGRAM_TOBJ_$__INIT$$LONGBOOL (= tobj.init) calls fpc_help_constructor, which allocates the memory if necessary (based on the size in the VMT, and the VMT is loaded in %edx in the code above).
More information about the fpc-pascal