From 3ce25bc348a84c43ae4b15f8c7d8cff908da668b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Sep 2016 08:41:13 +0200 Subject: [PATCH] - fixed: FxPreIncrDecr depended on undefined compiler behavior. It could only work with right to left function argument processing, but with left to right it failed because the ParseExpressionA call altered sc.TokenType. Note that with register-based arguments on 64 bit platforms this is a very critical issue! --- src/thingdef/thingdef_exp.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/thingdef/thingdef_exp.cpp b/src/thingdef/thingdef_exp.cpp index 991e9b947a..cad6198f04 100644 --- a/src/thingdef/thingdef_exp.cpp +++ b/src/thingdef/thingdef_exp.cpp @@ -309,7 +309,8 @@ static FxExpression *ParseExpressionC (FScanner &sc, PClassActor *cls) static FxExpression *ParseExpressionB (FScanner &sc, PClassActor *cls) { sc.GetToken(); - switch(sc.TokenType) + int token = sc.TokenType; + switch(token) { case '~': return new FxUnaryNotBitwise(ParseExpressionA (sc, cls)); @@ -325,7 +326,7 @@ static FxExpression *ParseExpressionB (FScanner &sc, PClassActor *cls) case TK_Incr: case TK_Decr: - return new FxPreIncrDecr(ParseExpressionA(sc, cls), sc.TokenType); + return new FxPreIncrDecr(ParseExpressionA(sc, cls), token); default: sc.UnGet();