out vs. var (was: Re: [fpc-devel] Internal error in FPC 2.6.0rc1)

Michael Müller mueller_michael at alice-dsl.net
Tue Nov 29 15:30:23 CET 2011


Am 28.11.2011 um 13:12 schrieb Jonas Maebe:

> 
> On 28 Nov 2011, at 12:02, Michael Müller wrote:
> 
>> Am 28.11.2011 um 01:05 schrieb Jonas Maebe:
>> 
>>> If you enable hints, the compiler will print a hint if it detects you passing a potentially uninitialized variable to a "var" parameter, while it won't print such a warning if you pass it to an "out" parameter.
>> 
>> But inside the routine with "out" parameter I had expected to get the same warning ;-).
> 
> You do get a warning if you use an "out" parameter inside a routine without first writing to it.

But only if you try to access an array element. I would have expected to get such a warning also when using Length(), Low() or High() (which I did in my original example). But I assume this difference is coming from how an array is handled. Even without using SetLength() I assume that just by declaring an array variable there is an internal structure that contains the array length field and the pointer to the element block. And there is no possibility to differ between an uninitialized (since initialized internally) and a SetLength(, 0) or array := nil. Is this correct?

Regards

Michael


More information about the fpc-devel mailing list