Re: D7 Compiler Bug
From: Jamie (jamie_5_not_valid_after_5_Please_at_charter.net)
Date: Fri, 24 Sep 2004 13:27:02 -0700
> Unfortunately the existence of calls to InitializeRecord etc. is not a proof
> for correct code creation of the compiler, since these calls can be forced by
> dynamic elements in the "top level" data type, or by the existence of local
> variables of the affected types. It's also hard to determine which fields of a
> datastructure are processed by InitializeRecord and FinalizeRecord, since the
> offsets of the affected fields are passed to these subroutines in a hidden data
> Sample code:
> TBase = Object
> s: string;
> TDerived = Object(TBase)
> procedure test;
> var obj: TDerived; //okay for TBase!
> assert(obj.s = '', 'uninitialized dynamic variable');
the compiler is doing exactly what it should be doing, the string is
treated like any standard string that you may create
at the entry point of a block.
also take not that you are not using the dynamic type of objects which
would be the Tobject in this case, but the objects which came first.
i know its nice the delphi still supports these types and i am glad
that they do.
these types are static types in the way you did it.
you need to initiate the code your self.
its no different from the need to clear the string or define it to
something on the entry of a code block.
the years of TP i did i never saw any docs stating that these objects
were initiated automatically, you may also want to take note that this
kind of string your using is not the default 255 byte long string but a
specify a size of 255 or less in the string instead and then you will
have the exact of TP.