Problem with uninitialized variables in ZScript

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:

Problem with uninitialized variables in ZScript

Post by Nash »

Code: Select all

        if (character)
        {
            Array<LADItem> tmp;
            LADItem LastItem;

            for (int i = 0; i < character.myItems.Size(); i++)
            {
                LastItem = character.myItems[i];


                // this gets an unintialized variable warning!!!
                if (tmp.Size() == 0)
                {
                    tmp.Push(LastItem);
                    continue;
                }
            }
        }
 
With the latest fixes in the engine, that if (tmp.size() == 0) line now always generates a warning. What can I do about this? There are a lot of occurrences like this all over my project (with regards to uninitialized dynamic arrays) and I'm not sure what's the solution here. I'd rather not ship my project with 10 billion warnings...
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: Problem with uninitialized variables in ZScript

Post by Graf Zahl »

That's a bug. Apparently _mental_'s check went too far. AFAIK the stack always gets nulled before use, and arrays are definitely being constructed - the only case where a variable does not get initialized is if a register gets reused for a second variable in the same function.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Problem with uninitialized variables in ZScript

Post by _mental_ »

OK, I'll fix this when I can. The topic needs to be moved to Bugs.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Problem with uninitialized variables in ZScript

Post by Blue Shadow »

_mental_ wrote:The topic needs to be moved to Bugs.
Done.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Problem with uninitialized variables in ZScript

Post by _mental_ »

I removed the warning completely in 4beefb7 for now. I hope it's temporary measure. This feature definitely requires more effort to be implemented properly.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Problem with uninitialized variables in ZScript

Post by Nash »

I do hope a more proper solution can be devised. I am in agreement for the uninitialized variable checks... but it needs to be less aggressive (?).
Post Reply

Return to “Closed Bugs [GZDoom]”