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

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Nov 28 13:12:59 CET 2011


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.

> Why is this 'passing a potentially uninitialized variable to a "var"  
> parameter' ('bla does not seem to be initialized') message a warning  
> for arrays and a hint for basic types?

It's only a warning for dynamic arrays. And the cause is a side effect  
of the way a "dynamic array" is internally converted to an "open  
array". It shouldn't be very difficult to fix that though.

> I don't understand this restriction. In the code High() works for  
> open arrays at run time.


See Sven's answer.


Jonas


More information about the fpc-devel mailing list