-
Notifications
You must be signed in to change notification settings - Fork 38.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
fix undefined conversion #117544
fix undefined conversion #117544
Conversation
Signed-off-by: Ruquan Zhao ruquan.zhao@arm.com
Hi @ruquanzhao. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @MikeSpreitzer |
I am not sure I understand the point here. (1) The cited doc does not assert that any numeric conversion is undefined. (2) The behavior I find in the go playground does not match what I thought the words in the doc meant. (3) Look at https://go.dev/play/p/_icC51O4TUO . It shows that the proposed change makes no difference. (4) A floating point value of -9.97e+07 is well within the range that converts to ints with no surprise. (5) Thanks for catching the typo. |
/ok-to-test |
@MikeSpreitzer Thanks for your reply!
which means something like
Yes, -9.97e+07 is in range int64 but not in range uint64. |
/retest |
@ruquanzhao : thanks for the clarification and counter-example. I had interpreted those words differently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Thanks!
LGTM label has been added. Git tree hash: cec22964a09bd09beb75777d4e66a347bc7a2210
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MikeSpreitzer, ruquanzhao The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
BTW, typo in the title here: it is spelled "conversion". |
/release-note-none |
Thanks! BTW |
Signed-off-by: Ruquan Zhao ruquan.zhao@arm.com
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR fixes an
uint64(f float64)
convertion which is an undefined behavior when thef <= -1
.ref: https://go.dev/ref/spec#Conversions
In this testcase, thinkDuration = -1, which will eventually result in uint(-9.97e+07).
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: