Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Generic MMBasic bug with STATIC
Author | Message | ||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3841 |
Spun off from here: https://www.thebackshed.com/forum/ViewTopic.php?TID=13459&PID=169564 Present on CMM2 and (according to @matherp) latest development version of the MM2 firmware: > list "static-bug.bas" Option Explicit On Option Default None Option Base 0 If foo%(10) = 11 Then Print "1: PASS" Else Print "1: FAIL" If bar_1%(11) = 11 Then Print "2: PASS" Else Print "2: FAIL" If bar_1%(0) = 11 Then Print "3: PASS" Else Print "3: FAIL" If bar_2%(foo%(10)) = 11 Then Print "4: PASS" Else Print "4: FAIL" If bar_2%(0) = 11 Then Print "5: PASS" Else Print "5: FAIL" Function foo%(a%) foo% = a% + 1 End Function Function bar_1%(b%) Static static_1% = -1 If static_1% = -1 Then static_1% = b% bar_1% = static_1% End Function Function bar_2%(c%) Static static_2% = -1 If static_2% = -1 Then static_2% = c% bar_2% = static_2% End Function > run 1: PASS 2: PASS 3: PASS 4: PASS 5: FAIL The problem appears to be something to do with the initialisation of a STATIC variable from a function parameter that is itself the "temporary" result of another function call. Best wishes, Tom Edited 2021-05-28 21:55 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
Good grief. That does not look easy. Thanks for the report and demo code. I will have a crack at it for the next version. Geoff Geoff Graham - http://geoffg.net |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3841 |
Thanks Geoff, I promise I came across it guilelessly from a genuine use-case and was not sequestered in my shed trying to come up with brain-twisters for Peter Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
That's great. Either way, bit by bit, bug by bug, these pesky "features" are being found and eliminated. BTW thank you very much for the demo code. I have found that a short demonstration of a bug (like this) can save a huge amount of time isolating it. Geoff Geoff Graham - http://geoffg.net |
||||
Print this page |