Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Misc > Re: FPC 2.1.4: ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< 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:
FPC 2.1.4: Impressions, bugs, questions
Wolfgang.Ehrhardt.PLEASE.  2007-05-26 14:27:18 
Re: FPC 2.1.4: Impressions, bugs, questions
Marco van de Voort <ma  2007-05-26 19:04:34 
Re: FPC 2.1.4: Impressions, bugs, questions
Wolfgang.Ehrhardt.PLEASE.  2007-05-26 19:38:34 
Re: FPC 2.1.4: Impressions, bugs, questions
Wolfgang.Ehrhardt.PLEASE.  2007-05-26 21:34:57 
Re: FPC 2.1.4: Impressions, bugs, questions
Marco van de Voort <ma  2007-05-27 08:50:22 
Re: FPC 2.1.4: Impressions, bugs, questions
Jonas Maebe <Jonas.Mae  2007-05-29 14:34:53 
Re: FPC 2.1.4: Impressions, bugs, questions
Wolfgang.Ehrhardt.PLEASE.  2007-05-29 17:32:15 
Re: FPC 2.1.4: Impressions, bugs, questions
Jonas Maebe <Jonas.Mae  2007-05-29 20:34:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 16:18:36 CDT 2008.