[fpc-pascal] FPC bug or brain bug ?
Flávio Etrusco
flavio.etrusco at gmail.com
Thu May 27 21:51:10 CEST 2010
All TObject descendants have a VMT. The destructor is virtual, BTW.
-Flávio
On Thu, May 27, 2010 at 11:01 AM, Yann Bat <batyann811 at gmail.com> wrote:
> Hi,
>
> I don't understand why compilation of the program below failed in fpc
> and objfpc mode. In tp and delphi mode it works as expected but in fpc
> and objfpc mode the compiler complains :
>
> blob.pas(17,3) Error: Constants of objects containing a VMT aren't allowed
> blob.pas(17,3) Fatal: Syntax error, ";" expected but "(" found
>
> Since my object has no virtual methods why a VMT ?
>
> Thanks.
>
>
> {$mode fpc}
> program Blob;
>
> type
> TBlob = object
> private
> fId : LongInt;
>
> public
> constructor Init;
> function Id: LongInt;
> end;
>
> PBlob=^TBlob;
>
> const
> NullBlob : TBlob = (fId: 0);
>
> {=== TBlob ===}
> constructor TBlob.Init;
> begin
> fId:=Random(1024) + 1;
> end;
>
> function TBlob.Id;
> begin
> Id:=fId;
> end;
>
> var
> B : TBlob;
> begin
> B:=NullBlob;
> WriteLn('B : ', B.Id);
>
> B.Init;
> WriteLn('B : ', B.Id);
> end.
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list