You are here

[Fixed] Range Check error in debug build

5 posts / 0 new
Last post
dummzeuch
dummzeuch's picture
Offline
Last seen: 1 year 6 months ago
Joined: 2020-11-01 12:28
[Fixed] Range Check error in debug build

I just downloaded the latest source archive from SourceForge (PortableAppsPlatformSource17.1.1.7z) and tried to compile and run it in debug mode. I immediately got a Range Check error here:

unit main.pas, Line 1905:

for iControl := 0 to length(arrAppButtonForegrounds) do
if (TObject(arrAppButtonButtons[iControl]) = Sender) or (TObject(arrAppButtonForegrounds[iControl]) = Sender) then

Which is correct because arrAppButtonForegrounds is declared as

arrAppButtonForegrounds: array [0..19] of TImage;

which means that Length(arrAppButtonForegrounds) = 20.

The correct code would be:

for iControl := 0 to length(arrAppButtonForegrounds)-1 do

or better:

for iControl := Low(arrAppButtonForegrounds) to High(arrAppButtonForegrounds) do

Are these really the current sources of the program? Doesn't anybody ever run them in the debugger?

edit: The same problem is in line 1979 and again in line 1994, 3678, 3740, 3784, 3795, 3811,

John T. Haller
John T. Haller's picture
Offline
Last seen: 1 hour 9 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Delphi Debugger

Thanks for the heads up. I just got Delphi working again a couple months after moving to a new PC. I always had issues with the debugger on my old PC. Is there a debugger setting to get range issues like this to show up? I have overflow and range checking enabled but it doesn't warn on this.

Sometimes, the impossible can become possible, if you're awesome!

dummzeuch
dummzeuch's picture
Offline
Last seen: 1 year 6 months ago
Joined: 2020-11-01 12:28
I only enabled overflow and

I only enabled overflow and range checking (which I do for every project in debug mode). Once I got the first few runtime errors I simply grepped for similar source code constructs which gave me the list I posted.

John T. Haller
John T. Haller's picture
Offline
Last seen: 1 hour 9 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Working Now, Thanks

Very weird, but after upgrading to this week's Delphi 10.4.2 release, the range check error is successfully coming up when I run it in Debug configuration. I made no changes to the configuration at all but Delphi 10.4.1 Patch 2 and earlier weren't throwing the error on my old PC or my new-to-me less old PC. Very odd. It's working now, though, so thanks for the heads up. I'll put together a build to fix this issue in the next few days.

Sometimes, the impossible can become possible, if you're awesome!

John T. Haller
John T. Haller's picture
Offline
Last seen: 1 hour 9 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Fixed in 18 Beta 1

This issue should be fixed in 18 Beta 1. I'll leave it open until it goes stable.

18.0 is stable and released, so this is fixed.

Sometimes, the impossible can become possible, if you're awesome!

Log in or register to post comments