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
BUG: Overflow reported when negating uint64 #24737
Comments
I can reproduce this. It looks like this changed sometime after NumPy 1.23, with the 1.23.3 wheel:
and the NumPy 1.24.3 wheel:
|
Works for me: gcc 13.2.1 in the development branch. Apparently C++ does have a preference, the hex literal has the type of the first type where it fits:
Maybe that is related? I assume the conversion is done by Python or a library. |
This needs a decision that we want to allow some scalar operators to wrap silently to users while we warn for others. |
Would it be possible to separate unary negation from multiplication by a negative number, where unary would not warn? |
Yes, we can do all of that. We just need to decide to do it. |
IMO it's safer to offer a warning that can be suppressed than to remove the warning because the underlying operation is sometimes intended. The behavior is still noteworthy in some cases and I think it is safe to optimize for those cases. |
In the latest triage meeting we decided to close this for now. In the future, we would prefer that scalars perform more like 0d arrays (and not warn), but that would be part of a larger effort and may even need a NEP. |
Describe the issue:
A usually valid operation, negation of an unsigned integer, is raising an underflow warning.
Reproduce the code example:
Error message:
`RuntimeWarning: overflow encountered in scalar negative`
Runtime information:
Context for the issue:
Wrapping unsigned integer values is fairly common in C using negation. This used to be free from warnings, so was surprised to see this.
The text was updated successfully, but these errors were encountered: