Closed Liosan closed 4 years ago
Thanks for notifying us. While this "same-type" assumption is made throughout the Unreal expresso script system, we will include a fix for the most common comparison operators regarding the float and int mismatch, including <, >, >=, <=, == and !=, in the next release.
Hello :) We are running Articy with Unreal, using this plugin, and we have run into an issue that seems rather... disturbing.
Consider the following Expresso condition:
getProp(getObj("Player"), "PlayerProperties.Intimidation") < 3
PlayerProperties.Intimidation is a float, and is compared against an integer value. I would expect the condition to evaluate to true if the float value is larger than 3.0, and false otherwise. The result, however, is undefined behaviour.
After debugging, I managed to track down the issue. The generated C++ looks like this:
This causes an implicit cast - the value 3 is cast to ExpressoType with type set to Int. Then, ExpressoType::operator< is evaluated; however, this operator assumes that both expressions are of the same type; it just performs
GetFloat() < Other.GetFloat()
. However, in this case Other is an Int; so we are reading undefined values from a union.