Arrays of dynarrays can't be indexed correctly

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!

Arrays of dynarrays can't be indexed correctly

Postby phantombeta » Tue Jan 08, 2019 11:18 am

When you try to index a dynarray contained inside an array with a non-constant index, it'll error out with "Invalid resizable array".
Code: Select allExpand view
    void foo () {
        Array<int> a [5];
        a.Push (555);

        a [3] [0] = 666; // This works fine
        int b = random (0, 255);
        a [b] [0] = 666; // This errors out
    }


Steps to reproduce:
  • Try to load the example PK3

I'd really like to see this bug fixed. Right now, the only way to get the array's contents is to copy it to a local variable.
I actually tried to see if I could fix it myself, but couldn't figure anything out. :\
Attachments
NestedDynArrayIndexBug.PK3
(371 Bytes) Downloaded 1 time
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

Re: Arrays of dynarrays can't be indexed correctly

Postby Graf Zahl » Tue Jan 08, 2019 11:25 am

phantombeta wrote:I actually tried to see if I could fix it myself, but couldn't figure anything out. :\


Welcome to the club. :( This one got me, too.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Arrays of dynarrays can't be indexed correctly

Postby phantombeta » Tue Jan 08, 2019 11:49 am

One thing I did figure out is that the constant case works because it pretty much turns constant index array accesses into temporary fields, if that helps at all.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_

Re: Arrays of dynarrays can't be indexed correctly

Postby Graf Zahl » Tue Jan 08, 2019 1:16 pm

I ran into this myself when scriptifying the AutouseHealth function, but I didn't manage to fix it.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Bugs

Who is online

Users browsing this forum: No registered users and 2 guests