Assertion failure with unary minus on bool

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
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Assertion failure with unary minus on bool

Post by _mental_ »

Loading the following ZScript will trigger an assertion failure here: ValueType is "Int" while Operand->ValueType is "Bool".

Code: Select all

class UnaryMinusBool : Actor
{
	states
	{
	spawn:
		TNT1 A 1
		{
			bool a = false;
			int i = -a;
			
			bool b = true;
			int j = -b;
			
			console.printf("%i %i", i, j);
		}
	}
}
Generated code seems to be correct. The sample outputs expected values, 0 and -1.
I suspect the assertion's condition is too strict and doesn't take bool-to-int type propagation into account.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Assertion failure with unary minus on bool

Post by Graf Zahl »

The problem is that the Resolve function does not properly promote the type if the operand is bool.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Assertion failure with unary minus on bool

Post by _mental_ »

Made this PR to be sure I got it right. As expected with this change generated code remains the same.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Assertion failure with unary minus on bool

Post by Graf Zahl »

That's correct.
Post Reply

Return to “Closed Bugs [GZDoom]”