OK, I am still trying to understand why my variant assignment statement causes subsequent POKE$ operations to silently fail. I think my first program might have been too long to expect people to look at it. I've tried again with the simplest possible program that demonstrates what I am now suspecting is a bug in PBCC 5.0 with variant array assignment.
BTW, Yes - I *know* variant assignment is slow and not a good way to copy arrays, but I believe this code demonstrates a problem with its implementation. Such a problem could easily affect legitimate uses of it, causing programs to silently fail, producing incorrect results that are very difficult to trace in production code.
Please, could someone try running this program on their system and see if they also always get to the line indicating "Arrays not equal."? Thanks.
BTW, Yes - I *know* variant assignment is slow and not a good way to copy arrays, but I believe this code demonstrates a problem with its implementation. Such a problem could easily affect legitimate uses of it, causing programs to silently fail, producing incorrect results that are very difficult to trace in production code.
Please, could someone try running this program on their system and see if they also always get to the line indicating "Arrays not equal."? Thanks.
Code:
#DIM ALL %LAST = 98664440 GLOBAL gArray1() AS LONG, gArray2() AS LONG, gVar AS VARIANT FUNCTION PBMAIN() AS LONG DIM i AS LONG REDIM gArray1(%LAST), gArray2(%LAST) FOR i = 0 TO %LAST gArray1(i) = RND(1,999) NEXT i 'NOTE: Once this line executes, the POKE$ silently fails. gVar = gArray1() : gArray2() = gVar REDIM gArray2(%LAST) 'NOTE: With %LAST >= 98664440, this line will silently fail. POKE$ VARPTR(gArray2(0)), PEEK$(VARPTR(gArray1(0)), 4 * (%LAST+1)) FOR i = 0 TO %LAST IF gArray1(i) <> gArray2(i) THEN STDOUT "Arrays not equal. Press any key..." WAITKEY$ EXIT FUNCTION END IF NEXT i STDOUT "Arrays were equal. Press any key..." WAITKEY$ END FUNCTION
Comment