[fpc-pascal] Incorrect hint message ? ( Hint: Local variable "b" does not seem to be initialized" )

Vinzent Hoefler JeLlyFish.software at gmx.net
Wed Aug 22 11:09:34 CEST 2007


On Wednesday 22 August 2007 06:30, Skybuck Flying wrote:

> "project1.lpr(21,5) Hint: Local variable "b" does not seem to be
> initialized"

[...]

> However when looking at the source code this hint message seems
> inaccurate.
>
> B is initialized by the procedure test.

No, it's not. It says "var", so according to the contract the procedure 
"test" is supposed to get an already initialized value (and may change 
it when executing).

[...]

> procedure test( var b : byte );
> begin
>     b := 5;
> end;

[...]

If you want "test" to really initialize the variable and not care about 
its incoming value, you should use parameter mode "out" instead.


Vinzent.




More information about the fpc-pascal mailing list