[fpc-devel] bug: Inc(v,i)/Dec(v,i)
Vinzent Hoefler
JeLlyFish.software at gmx.net
Fri Jul 8 11:22:09 CEST 2005
On Thursday 07 July 2005 21:27, Marcel Martin wrote:
> Vinzent Hoefler a écrit :
>
> > Personal note: Maybe there was a reason why Borland Pascal didn't
> > do range checks on Inc/Dec.
>
> Yes, there is always a good reason for a bug :-)
Any sufficiently advanced bug cannot be distinguished from a
feature. :-)
> If ever you changed that, i.e., if you suppressed the overflows
> with Inc and Dec, thanks to let us know explicitely (here, for
> instance).
Full ACK. They have to document it either way (and in the past they
did).
> Personally, I would have to rewrite a few lines of
> code, like, for instance, in
>
> procedure XDiv2(X: PBigFloat);
> begin
> with X^ do if not IEqu0(Mantissa) then {$Q+} Dec(Exponent); {$Q-}
> end;
Yeah. Sure. Same reason I had to rewrite:
| for i := 0 to Buf_Len - 1 do
| begin
| b := tByteArray (Buf)[i];
| Inc (C_Sum, b); { work around range check error RRG/VH 161100 }
| ComOut (P_Nr, b);
because after we decided to port the whole stuff to Linux, FPC broke the
code again. :-)
> > The only time I ever used it was a checksum
> > calculation which was modulo anyway. Any other time I use the usual
> > operators. So especially with the "added" overflow check I think,
> > Inc and Dec are pretty useless functions, because the don't do
> > anything you can't accomplish by using "+" or "-" unless you have
> > very_long_and_complex_variable_names and want to save some typing
> > work.
>
> That's a matter of habit. Not sure but I believe that with TP3,
> the compiled code was better with "Inc" than with "+".
Yes, it used a direct memory increment which was better on the
processors we used back then. Interestingly with the introduction of
the Pentium 10 years ago which (in most cases) could execute the
mem-store/reg-inc/mem-store faster than the direct in-memory-addition
this optimization fired back. Of course then it didn't matter that much
anymore, 'coz the processor was too fast already. ;-)
Vinzent.
--
public key: http://www.t-domaingrabbing.ch/publickey.asc
More information about the fpc-devel
mailing list