Closed JJFlash-IT closed 4 years ago
Hi Thanks for reporting this issue. I can confirm that there is a bug here. It seems that the addresses of 2 dimensional array members are not correctly resolved. I'll fix this ASAP.
Fixed now. Please download v2.2.05 from here: https://github.com/neilsf/XC-BASIC/releases/tag/v2.2.05
Downloaded! I tried the same program above and now it seems to work perfectly!
0 0 3127
1 0 3128
0 1 3129
1 1 3130
0 2 3131
1 2 3132
0 3 3133
1 3 3134
0 4 3135
1 4 3136
0 5 3137
1 5 3138
3139
3140
3141
3142
I can see now that it only messed up during the 1D index calculation, not during the variable "allocation", hence the overwriting. Thanks again!
Hello (and sorry for my English, I'm from Italy)! I think I found a bug regarding the handling of 2D byte(!) arrays: I was porting a little Freebasic demo of mine to XC=BASIC, and I had a really hard time figuring out why the program was crashing and behaving erratically. After some debugging, I saw that some of the byte(!) variables I used were getting overwritten with seemingly random values. Thanks to the @ operator, I think I finally figured it out.
If you try to compile and run this (note: I'm using version 2.2.03 because that's reported as the stable version on the xc-basic site at the moment):
You'll see this as output:
With this, you can see that
Variable1!
andVariable2!
share the same address as the [2,0] and [2,1] elements ofArray!
! If you declare the Array last instead of first (after the byte variables, I mean), there will be no conflict of address.I haven't tested integer and float 2D arrays for the same behaviour.
Incidentally: why that jump of 5 bytes in the array elements? Shouldn't they be contiguous? Probably there's something I'm missing :)
Thanks and keep up the great work! Apart from this problem, I really enjoyed the porting experiment! :D