-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Possible bug in ValueType.GetHashCode() for fields smaller than 4 bytes #9746
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
Comments
Same in FastGetValueTypeHashCodeHelper |
@danmosemsft - Yes in the case of a struct that is tightly packed and is less than 4 bytes in size.... |
@tomspilman the same issue is by replacing |
Yes it occurs with any type less than 4 bytes. |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
This issue will now be closed since it had been marked |
I found the results of
GetHashCode()
odd for a struct i was testing:https://dotnetfiddle.net/BTgRga
The reason i get these results seem to be coming from this line:
https://github.com/dotnet/coreclr/blob/master/src/vm/comutilnative.cpp#L2129
It does
(INT32)(fieldSize / sizeof(INT32))
and whenfieldSize
is less than 4 we get 0 which results in no hash contribution for the field.While this is a valid result for
GetHashCode()
it doesn't seem to be the intent of the code written and may be a bug.The text was updated successfully, but these errors were encountered: