'out' can be ommited in overrides, causing silent bugs.

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

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!
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

'out' can be ommited in overrides, causing silent bugs.

Post by Accensus »

Take this code for example:

Code: Select all

class BaseClass abstract
{
	abstract void F1(out int ticker);
	abstract void F2(out int ticker);
}

class DerivedClass : BaseClass
{
	override void F1(out int ticker)
	{
		Console.Printf("F1: %i", ticker);
	}
	override void F2(int ticker)
	{
		Console.Printf("F2: %i", ticker);
	}
}

class OutParamTest : Actor
{
	override void BeginPlay()
	{
		Super.BeginPlay();
		cls = new('DerivedClass');
	}
	override void Tick()
	{
		cls.F1(Ticker);
		cls.F2(Ticker);
		Ticker++;

		Super.Tick();
	}

	int Ticker;
	BaseClass cls;
}
This results in F1 printing the correct number: 0, 1, 2, 3 and so on, but F2 prints out some 10 digit negative number.

I had this happen in some code elsewhere and had to spend some good 20 minutes to figure out where the problem was exactly. Shouldn't this be a warning at the very least? This also sounds like a possible security concern.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: 'out' can be ommited in overrides, causing silent bugs.

Post by Marisa the Magician »

Rather than a warning this should be an error outright if it causes issues like those.

Especially because warnings tend to get largely ignored by most modders.
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: 'out' can be ommited in overrides, causing silent bugs.

Post by Accensus »

Wouldn't that break existing mods? Unless it only errors past a certain version, but I don't know how possible that'd be for something like this.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: 'out' can be ommited in overrides, causing silent bugs.

Post by Marisa the Magician »

Sometimes you have to risk breakage to fix such a huge oversight, especially because this appears to be causing undefined behavior.
User avatar
nova++
Posts: 177
Joined: Sat Sep 04, 2021 3:13 am

Re: 'out' can be ommited in overrides, causing silent bugs.

Post by nova++ »

Yeah, it sounds like this is enough of an issue that breaking stuff that might be using/abusing it would be a good thing.
Post Reply

Return to “Bugs [GZDoom]”