

|
 |
| Programming > Pascal Misc > Re: FPC 2.1.4: ... |
|
| << Topic |
< Post |
Post 8 of 8 Topic 738 of 810
|
Post > |
Topic >> |
Re: FPC 2.1.4: Impressions, bugs, questions
by Jonas Maebe <Jonas.Maebe@[EMAIL PROTECTED]
>
May 29, 2007 at 08:34 PM
| In article <465c6107.467143@[EMAIL PROTECTED]
>,
Wolfgang.Ehrhardt.PLEASE.REMOVE@[EMAIL PROTECTED]
(Wolfgang Ehrhardt)
wrote:
> >> var
> >> f: text;
> >> n: integer;
> >> begin
> >> assign(f,'test'); <=
> >> reset(f);
> >> readln(n); <=
> >> writeln(n);
> >> end.
> >>
> >> ex.pas(5,3) Hint: Variable "f" does not seem to be initialized
> >> ex.pas(7,3) Hint: Type size mismatch, possible loss of data / range
> >> check error
> >
> >You seem to be compiling with 2.0.4 here, as the first hint is no
longer
> >printed by 2.1.4. The second one still is, however.
> >
>
> Yes, right you are! (But the second is more annoying as it appears
> very often).
The hint is correct, however. Readln will read an ordinal value in an
integer of the native bitsize (except when reading a 64 bit value on a
32 bit system, in which case a 64 bit value is read). Then it's assigned
to the parameter, which in the above application is a 16 bit integer.
If range checking is on, this can lead to range errors, and without it
to data loss. I understand that this can happen in many situations in
real world programs, but hints are mainly intended as a "last resort"
thing to turn on if you have a bug which you just cannot find, and want
to see all possible places in your code where something just might go
wrong.
Otherwise, you may indeed better stick with warnings and notes.
Jonas


|
8 Posts in Topic:
|
Wolfgang.Ehrhardt.PLEASE. |
2007-05-26 14:27:18 |
|
Marco van de Voort <ma |
2007-05-26 19:04:34 |
|
Wolfgang.Ehrhardt.PLEASE. |
2007-05-26 19:38:34 |
|
Wolfgang.Ehrhardt.PLEASE. |
2007-05-26 21:34:57 |
|
Marco van de Voort <ma |
2007-05-27 08:50:22 |
|
Jonas Maebe <Jonas.Mae |
2007-05-29 14:34:53 |
|
Wolfgang.Ehrhardt.PLEASE. |
2007-05-29 17:32:15 |
|
Jonas Maebe <Jonas.Mae |
2007-05-29 20:34:46 |
|
Post A Reply:

|
|
|
|