Indy 10.0.52 Range Check Error BUG

Giganews Newsgroups
Subject: Indy 10.0.52 Range Check Error BUG
Posted by:  orlando (seasidebru…@hotmail.com)
Date: Wed, 6 Apr 2005

First, I want to acknowledge that Indy is a wonderful tool and TeamB has
been very helpful.

I want to report the bug below with Indy 10.0.52... we get a range check
error

Indy 10 for Delphi 6\Source\System\IdGlobal.pas
=======================================
{$IFDEF MSWindows}
// S.G. 27/11/2002: Changed to use high-performance counters as per
suggested
// S.G. 27/11/2002: by David B. Ferguson (david.m…@ns.sympatico.ca)
function Ticks: Cardinal;
var
  nTime, freq: Int64;
begin
  if Windows.QueryPerformanceFrequency(freq) then begin
    if Windows.QueryPerformanceCounter(nTime) then begin
      Result := Trunc((nTime / Freq) * 1000)
    end else begin
      Result := Windows.GetTickCount;
    end;
  end else begin
    Result:= Windows.GetTickCount;
  end;
end;
{$ENDIF}
=================================

Line 1380:      Result := Trunc((nTime / Freq) * 1000)
has caused a "range check error" for us.  The reason being that the
"Trunc((nTime / Freq) * 1000)" resulted in a value that was higher than
High(Carnial).
My work around was as follows:
-----------
      if Trunc((nTime / Freq) * 1000)>High(Cardinal) then
        Result := High(Cardinal)
      else
        Result := Trunc((nTime / Freq) * 1000)
---------------

Replies