Skip to content
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

Default hashcode for struct with double or float field is wrong #9802

Closed
jkotas opened this issue Feb 24, 2018 · 3 comments
Closed

Default hashcode for struct with double or float field is wrong #9802

jkotas opened this issue Feb 24, 2018 · 3 comments

Comments

@jkotas
Copy link
Member

jkotas commented Feb 24, 2018

Repro:

using System;

struct StructWithDoubleField
{
    public double value;
}

class My {

    static void Main() {
        StructWithDoubleField s1;
        s1.value = 0.0;
        StructWithDoubleField s2;
        s2.value = -0.0;

        Console.WriteLine(s1.GetHashCode() == s2.GetHashCode() ? "PASSED" : "FAILED");
    }

}
@mikedn
Copy link
Contributor

mikedn commented Feb 24, 2018

The default GetHashCode implementation for structs should have been throw new NotSupportedException("Tomato!"); 😁

@jkotas
Copy link
Member Author

jkotas commented Feb 24, 2018

dotnet/coreclr#13164 missed this case.

@dougbu
Copy link
Member

dougbu commented Apr 18, 2018

@jkotas what is the process to request porting at least the object field portion of the fix to a patch release? Given customer-reported downstream bugs such as aspnet/Mvc#7673, seems like we need this at least in 2.0.x.

/cc @davidfowl @Eilon @Petermarcu

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants