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

Flávio Etrusco flavio.etrusco at gmail.com
Fri May 29 09:44:13 CEST 2009


> (...)
>
> 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? I'm not 100% I've read it on any
official source, but I never saw it behave differently than "var
without the warning". Delphi didn't even have the decency to
force/warn one to initialize in the function :-/
Doesn't this have some implications on COM calls? Or is it like this
way exactly to make COM work?

>
> 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...

Best regards,
Flávio



More information about the fpc-devel mailing list