ZScript 2D array assignment and access orders swapped?

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

ZScript 2D array assignment and access orders swapped?

Post by Nash »

Mikk- wrote:Okay stupid question but can 2D arrays not have a larger second dimension than the first dimension?
Say for example I have an array defined as test[8][11] - if I then assign index [1][9] I get an out of bounds error..? but if I assign index[1][7] I do not get an error, which is rather strange...

Code: Select all

class c_arraytest : actor
    {
    
    int c_testarray[8][11];
    
    override void postbeginplay()
        {
        super.postbeginplay();
        
        c_testarray[1][9] = 1;
        }
    }
Gutawer wrote:It's kinda weird, but the assignment order for the dimensions and the access order are actually swapped around, you probably want int c_testarray[11][8] instead. That little problem had me annoyed for at least half and hour when I ran into it, lol.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript 2D array assignment and access orders swapped?

Post by Major Cooke »

If this is true, I better go back through D4D and untangle any multi-dimensional arrays immediately or there will be hell to pay when fixed.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript 2D array assignment and access orders swapped?

Post by Graf Zahl »

If this gets addressed it needs to be versioned. But of course with D4D that can be a problem, if it sees continued development...
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript 2D array assignment and access orders swapped?

Post by Major Cooke »

We've already broken D4D over multiple versions. I don't mind it.

At any rate, I don't think there are any multi-dimensional arrays being used zscript wise with D4D so far...
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: ZScript 2D array assignment and access orders swapped?

Post by phantombeta »

PR link. Versioned, obviously. Fixes array definitions for version 3.8.0 and above
Was actually pretty easy to fix.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript 2D array assignment and access orders swapped?

Post by Graf Zahl »

Heh. I was thinking about convoluted approaches on a later stage, I actually never thought about brute-force altering the parser's output on the AST level...
It should still use std::move to assign the swapped array (or swap in-place.)

This should also be versioned 3.7.2, I think, so it can be in the next point release.
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: ZScript 2D array assignment and access orders swapped?

Post by phantombeta »

Graf Zahl wrote:Heh. I was thinking about convoluted approaches on a later stage, I actually never thought about brute-force altering the parser's output on the AST level...
Sometimes a naive approach can be the best one. :P
It should still use std::move to assign the swapped array (or swap in-place.)

This should also be versioned 3.7.2, I think, so it can be in the next point release.
Done and done.
Post Reply

Return to “Closed Bugs [GZDoom]”