PB 5.73 - ReDim Array inside structure - IMA

Post bugreports for the Linux version here
User avatar
StarBootics
Enthusiast
Enthusiast
Posts: 754
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

PB 5.73 - ReDim Array inside structure - IMA

Post by StarBootics »

The following code is self explanatory.

Best regards
StarBootics

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : ReDim Array inside structure - IMA
; File Name : ReDim Array inside structure - IMA.pb
; File version: 1.0.0
; Programming : Bug Demonstrator
; Programmed by : StarBootics
; Date : 23-11-2021
; Last Update : 23-11-2021
; PureBasic code : 5.73 LTS
; Platform : Ubuntu 21.10 (Impish Indri) x86-64
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Bug Description :
;
; Apparently we can ReDim a multi-dimensions array calling
; ArraySize() instruction for the 1st dimensions without
; any problems.
;
; However if we try to do the same thing on an Array inside
; a structure we end up with an Invalid Memory Access
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Dim MyArray.l(5,5,5)

; This will work perfectly
ReDim MyArray(ArraySize(MyArray(), 1), ArraySize(MyArray(), 2), 10)

Structure MyStructure
  
  Array MyArray.l(5,5,5)
  
EndStructure 

Define MyVar.MyStructure

; This will work perfectly
D1 = ArraySize(MyVar\MyArray(), 1)
D2 = ArraySize(MyVar\MyArray(), 2)
ReDim MyVar\MyArray(D1, D2, 10)

; This will work perfectly
ReDim MyVar\MyArray(5, 5, 10)

; This will not work, IMA
ReDim MyVar\MyArray(ArraySize(MyVar\MyArray(), 1), ArraySize(MyVar\MyArray(), 2), 10)

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Enthusiast
Enthusiast
Posts: 754
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: PB 5.73 - ReDim Array inside structure - IMA

Post by StarBootics »

A little update about this problem since PB 6.00 Beta 1 has been released.

ASM Backend -> IMA
C Backend -> No problem

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
Post Reply