Page 1 of 1

Constants can be passed to "out" arguments, causes crashes

Posted: Mon Oct 21, 2019 7:55 am
by phantombeta
You can pass constant values to "out" arguments. Once the function call happens, this causes a crash. (Both with the VM and the JIT)
Passing a constant to an out parameter should error out. Mostly putting this here so I don't forget it.

Example code:

Code: Select all

class BEPlayerBase : DoomPlayer
{
	private void CheckCursorMovement(out int maxWidth, int maxHeight)
	{
		Console.Printf ("%d", maxWidth);
	}

	vector2 SomeGridCoords;

	override void Tick()
	{
		int buttons = player.original_cmd.buttons;
		int oldbuttons = player.original_oldbuttons;

		if (buttons & BT_ATTACK)
		{
			CheckCursorMovement(5, 5);
		}

		Super.Tick();
	}
}

Re: Constants can be passed to "out" arguments, causes crash

Posted: Tue Oct 22, 2019 2:12 am
by _mental_