-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
I64.min_value() / -1 returns unexpected results #2858
Comments
Apparently the first triggers undefined behavior in LLVM that I think we should discuss: http://llvm.org/docs/LangRef.html#id109 A discussion of how Julia handled is here: |
Looking at the implementation: ponyc/src/libponyc/codegen/genoperator.c Line 194 in a22e910
x/0 case.
GCC returns INT64_MIN, whereas Clang treats this as UB and optimizes everything out, even if Rust panics, even if overflows checks are disabled. Using the explicit "wrapping division" returns INT64_MIN. https://godbolt.org/g/Gr2mNC The best choice I think would be to just change that line in |
It seems like @mfelsche found that this behaviour is not giving the expected zero on arm and armhf? #2865 (comment) |
... and on windows it seems. |
So the inconsistency is only valid for |
This looks like something that needs to have the same behavior across all platforms. We should figure out what behavior is needed here. |
When running:
I would expect the value to wrap back around to I64.min_value because
min value = -9223372036854775808
max value = 9223372036854775807
and -9223372036854775808 / -1 should be 9223372036854775808
which given the I would expect to be be -9223372036854775808 as it is when I do when I run:
The text was updated successfully, but these errors were encountered: