Array.Pop with a Structure is buggy on ARM builds (Apple Silicon)

I’m finding some gnarly bugs with Structures on ARM (Apple Silicon) builds.

I suspect there are multiple issues, so I’m starting a new thread.

First report: https://tracker.xojo.com/xojoinc/xojo/-/issues/75286 Popping a Structure causes an OutOfBoundsException on ARM

See also Pure XOJO code works differently for MacOS intel / arm - #11 by Mike_D which seems like a worse bug - it doesn’t crash, but instead, the line

myStructure = MyArray.Pop

gives you the wrong data.

I haven’t found a way to reproduce that one yet.

1 Like

Data alignment in Intel and ARM may differ. That said, some codes being ported from one CPU to another, SPECIALLY STRUCTURES, may behave erratically if not prepared for such differences. Like in Intel something get an alignment 4 and ARM an alignment 8, and the total bytes in the struct gets bigger on ARM and your code has something hardcoded expecting a fixed number of bytes and it differs.

I’ll just let this here so someone checking about those struct issues being inspected may have more insights that could lead to finding what’s going on.