-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cpp] wierd addition results upon int overflow #8879
Comments
Ok, I've managed to reduce class Main {
static var b:Int = -1;
public static function main():Void {
var result = -2147483648 + b;
trace(result);
trace(result >= 0);
}
}
Analyzer is not involved. It's something about int overflow in cpp. |
What system are you on? Which I what I'm expecting. A different compiler may be doing something different with the LessThan template, which is where I would look next.
|
I'm on linux. class Main {
static var b:Int = -1;
public static function main():Void {
var result = -2147483648 + b;
trace('' + result); //2147483647
trace(result >= 0); //true
}
} Here is my system:
|
Given it only happens for a single int constant |
Wild guess: |
This is normal for GCC. There is a bunch of questions on SO about that. In C++ standard overflow of signed integers is considered an UB. There is a documented flag for GCC called |
Making any one of the following changes fixes it:
inline
accessor fromaddition
function;if
expression;analyzer-optimize
.The text was updated successfully, but these errors were encountered: