Re: ReadLn issues a warning

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ReadLn issues a warning

Gerhard Scholz
Hello,

this is a general feature when using an uninitialized variable as a VAR
parameter.

The compiler cannot know if the called routine needs the parameter values,
or if the parameter is only used to return values back to the caller.

So, I think, a warning here could be helpful (in the case of READ(LN ) not
of course, but in other cases).

Greetings

Gerhard

Date: Sat, 14 May 2005 12:12:50 +0200 (CEST)
From: Michael Van Canneyt <[hidden email]>
Subject: Re: [fpc-pascal] ReadLn issues a warning
To: FPC-Pascal users discussions <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: TEXT/PLAIN; charset=US-ASCII



On Sat, 14 May 2005, Yiannis Dondos wrote:

> Hello everybody,
>
> could you please tell me if there is something wrong with the following
> code:
>
> program test1;
>
> var
>    f: Text;
>    i: Integer;
>    s: ShortString;
>
> begin
>      Assign (f, 'test.dat');
>      Reset (f);
>
>      ReadLn (f, i);
>      ReadLn (f, s);  // Warning: Variable not initialized
>
>      Close (f);
> end.
>
> FPC 1.9.8 on Linux issues a warning that FPC 1.0.10 never did.
> The question is why the string variable needs to be initialized?

It does not need to be. The warning is bogus. This is a bug.

Michael.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: ReadLn issues a warning

Peter Vreman
> Hello,
>
> this is a general feature when using an uninitialized variable as a VAR
> parameter.
>
> The compiler cannot know if the called routine needs the parameter values,
> or if the parameter is only used to return values back to the caller.
>
> So, I think, a warning here could be helpful (in the case of READ(LN ) not
> of course, but in other cases).

It is a known issue for Readln() and Str(). The routines need to be
changed from 'var' to 'out'. But changing it short before the release was
too risky.




_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Loading...