QB64 crash!?
#1
Try this code and tell me what happens..

btw: It does not display an error..

Code: (Select All)
Print clock$

Function clock$
  clock$ = "date/time is:"
  clock$ = clock$ + Date$ + " " + Time$
End Function
Reply
#2
It generates a never-ending recursive call back to clock$, which keeps adding Date$ and Time$ to clock$, until they grow so large, you run out of memory and stack space and crash.
Reply
#3
I don't even need to run it to tell what will happen - the second line of the function is recursively calling the function, which repeats infinitely.  Change the function to do this instead:

c$ = "date/time is:"
clock$ = c$ + date$ + " " + time$
Reply
#4
Code: (Select All)
Print clock$

Function clock$
    _Delay .001
    Static count
    count = count + 1
    Print count; "recursive calls in..."
    clock$ = "date/time is:"
    clock$ = clock$ + Date$ + " " + Time$
End Function


[Image: image.png]


14,415 recursive calls to the function, and then it crashes for me. Wink
Reply
#5
Time after time, time after time, time after time...

- Cindi Lauper
Reply
#6
(12-21-2022, 04:26 AM)SMcNeill Wrote: It generates a never-ending recursive call back to clock$, which keeps adding Date$ and Time$ to clock$, until they grow so large, you run out of memory and stack space and crash.

My question was that since the following code crashes with an Out Of Memory box:

Code: (Select All)
Dim Large(1024, 1024, 1024, 1024) As Double

Obviously because you can't assign an 8 Terabyte array,

then why can't QB64 display an Out Of Stack box??

Erik.
Reply




Users browsing this thread: 2 Guest(s)