[fpc-devel] bug: Inc(v,i)/Dec(v,i)
Marcel Martin
mm10 at ellipsa.net
Thu Jul 7 23:27:13 CEST 2005
Vinzent Hoefler a écrit :
> On Thursday 07 July 2005 05:39, Peter Vreman wrote:
>
>
>>>shouldn't it implement inv(v,-1) in exactly the same way it
>>>implements v:=v-1?
>>
>>The problem is what type do you give to -1. In the old situation the
>>-1 was converted to the same type as v -> longword.
>
>
> Which should trigger a range check already, because -1 can't be
> represented as valid longword.
>
> 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 :-)
To the FPC team.
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). 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;
> 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 "+".
mm
More information about the fpc-devel
mailing list