Title sucks. Ran out of characters. Here's the situation:
Run the attached file and summon VarTest. The print result will be 0, 0, 1 for both the static and non-static calls. Array size will be 2. The correct and expected result is "0, 0, 0" with array size of 3.
Here are the two ways to "fix" this:
1. Uncomment the "Console.Printf(am.GetClassName());" lines. If something is referenced above the didInsert definition, the variable will be correctly initialized.
2. Explicitly initialize didInsert by setting it to false.
tl;dr something about the vars not being implicitly initialized.
Uninitialized vars in loop carried over to next iteration.
Moderator: GZDoom 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!
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!
-
- Posts: 2383
- Joined: Thu Feb 11, 2016 9:59 am
Uninitialized vars in loop carried over to next iteration.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 2147
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Uninitialized vars in loop carried over to next iteratio
This is caused by registers not being marked as dirty, so the local var init code thinks they're still clean and don't need to be implicitly initialized.
This is most likely going to be a pain in the ass to find every missing case of a missing dirty flag, so I'm personally not even touching this. If it just implicitly initialized anything without an initializer this wouldn't have ever happened, but y'know, possible microscopic performance losses were a bigger concern than ensuring safety here.
Oh, and by the way, this obviously means the uninitialized var reinterpret cast bug is still around, just harder to trigger.
This is most likely going to be a pain in the ass to find every missing case of a missing dirty flag, so I'm personally not even touching this. If it just implicitly initialized anything without an initializer this wouldn't have ever happened, but y'know, possible microscopic performance losses were a bigger concern than ensuring safety here.
Oh, and by the way, this obviously means the uninitialized var reinterpret cast bug is still around, just harder to trigger.
-
- Lead GZDoom+Raze Developer
- Posts: 49204
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Uninitialized vars in loop carried over to next iteratio
Obviously this is just a bad coding example. Regardless of what a language does, you should never *ever* operate on uninitialized variables.