-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/compile: incorrectly reports x - minimumValue
overflows for integers
#68628
Comments
I use This might be working as expected as far as the go spec goes, but then I think the language should be changed, reading |
CC @golang/compiler |
As you mentioned, this is working as intended. It is not reporting the result of the subtraction overflows, but the conversion of untyped int 32768 to int16 (which happens before the subtraction) overflows.
|
Working as expected as @cherrymui already explained. The This is just a typical edge case of fixed-width 2's complement arithmetic that one has to be aware of. We're not going to change the language for that. For one, making adjustments in the spec to comprehensively cover such cases would amount to a lot of complexity for very little benefit. Closing as working as intended. |
Go version
go version devel go1.24-0fe775e9f3 Mon Jul 29 05:12:05 2024 +0000 X:rangefunc linux/amd64
Output of
go env
in your module/workspace:What did you do?
compile the following code:
What did you see happen?
What did you expect to see?
Nothing (compiles successfully).
The text was updated successfully, but these errors were encountered: