[fpc-devel] Compiler hint for uninitialized local variable minor mistake

Jonas Maebe jonas.maebe at elis.ugent.be
Fri May 29 09:51:04 CEST 2009


On 29 May 2009, at 09:44, Flávio Etrusco wrote:

>> (...)
>>
>> This is due to the fact that if you pass a variable to an out  
>> parameter and
>> this variable is reference counted or contains reference counted  
>> elements
>> (in case of an array/record/object), then the compiler has to insert
>> finalization code at the caller side for this variable before  
>> passing it in.
>> The result is that if tmp is reference counted but nevertheless  
>> somehow
>> contained garbage, e.g. in a program like this:
>
> Is Delphi's behavior the same?

Yes.

> Doesn't this have some implications on COM calls? Or is it like this
> way exactly to make COM work?

Indeed.

>> Keep in mind that hints are the lowest level of "programming help"  
>> that the
>> compiler has to offer, and it is generally impossible to make your  
>> code hint
>> free. They are only intended to help you if you really are at wits  
>> end
>> regarding what could be going wrong. Otherwise, it's best to stick to
>> warnings and notes.
>
> And this make hints so much less useful...

That's the whole point of having a hints category: to put stuff in  
that we simply cannot guarantee to be useful (but which might be  
useful under some circumstances).


Jonas


More information about the fpc-devel mailing list