Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Bug Reports / For/Next Step -1 on a DWORD Type Index to 0 Crash

Author
Message
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 10th May 2010 23:53 Edited at: 12th May 2010 06:44
[DBPRO] <- Forgot to include in subject. sry.
OS: 64-Bit Vista
DBPro 1.075 beta 11

For me, running the code below alone will stop the application from running... ie: crash.

It has something to do with the For/Next index being set of type DWORD and using a step value of -1. When the index is stepped down to 0, it crashes.

In my project, I'm able to catch the index values through the win32 messagebox function and see that the for/next index does indeed tries to go pass 0 to DWORD equivalent of -1.

It will not stop at 0 as it should.

Of coarse, setting a higher value then 0 will work.

Setting the index to a type of Integer works.



-------

local local_index as DWORD

for local_index = 9 to 0 step -1
print local_index
next

wait key

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th May 2010 19:09 Edited at: 11th May 2010 19:15
This is why it doesn't work:



Dwords can never be negative so your for/next loop never terminates. I don't think it crashes - it's just stuck in the loop (and is very hard to stop as I've just discovered ).

Edit Just re-read your post. I think the issue here is that a for/next loop is skipped as soon as the index variable is greater/less than the final value when the step is positive/negative. It doesn't test for equality to the final value - that would cause other difficulties such as what to do with cases like "for i = 0 to 11 step 2".
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 11th May 2010 22:27 Edited at: 12th May 2010 06:44
Yeah, I feel I'm being a bit picky here. BUT... trying not to compare this to other languages...

Quote: "Dwords can never be negative so your for/next loop never terminates"


exactly, my point is here that the condition for a negative value should never occur.

1-1 = 0

1 and 0 are in the range of a DWORD values.

The compiled .exe should know when 0 is reached from the for/next statement with step -1. That condition should be met before any condition that leads step -1 to go pass 0. Thus, a DWORD value range should have no factor in this case, because like i said, the for/next -1 counter should never go under 0.

Yes, I know im in the land of work-arounds. My work-around was just to do something like:

for local_index = 10 to 1 step -1
` blah blah
next

and then compare it with what I needed with a -1 to it... like "SomeVariable> (local_index-1)" ... so (local_index-1) could be 0 to be compared with in my program's code proper.

logically to me, # to 0 step -1 on a DWORD type should indeed work. Once step -1 get's to 0, get'r done!

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th May 2010 01:58
Why not use the looping construct that does exactly what you want? You have a few to choose from after all.

I think you'll find that for/next loops work the way they are designed to work.

Why use a dword anyway?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 12th May 2010 02:24
Quote: "It doesn't test for equality to the final value - that would cause other difficulties such as what to do with cases like "for i = 0 to 11 step 2"."


It should do both, using either <= or >=. Should be a quick and easy fix if there's going to be an update any time soon.
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 12th May 2010 04:09 Edited at: 12th May 2010 06:44
I hear ya GG

I was just merely trying to point out this anomaly itself. I personally feel that this is a bug. It's not logical to me. So I thought I would share my findings and let it absorb itself in the bug forum soup.

Like I said above, I'm in the realm of work-arounds with DBPro and I have indeed already found a work-around.

Honestly, I do appreciate you trying to help out in any way you can. A valued member title well earned indeed. I would rather discuss with you when you will have the super fast Screen-Space Ambient Occlusion Shader ready for us

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th May 2010 14:08
Quote: "It should do both, using either <= or >=. Should be a quick and easy fix if there's going to be an update any time soon. "


Good point.

Quote: "I would rather discuss with you when you will have the super fast Screen-Space Ambient Occlusion Shader ready for us"


You might have to wait a bit.

Login to post a reply

Server time is: 2024-03-29 05:41:02
Your offset time is: 2024-03-29 05:41:02