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");
}
}
The default GetHashCode
implementation for structs should have been throw new NotSupportedException("Tomato!");
:grin:
https://github.com/dotnet/coreclr/pull/13164 missed this case.
@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
Most helpful comment
The default
GetHashCode
implementation for structs should have beenthrow new NotSupportedException("Tomato!");
:grin: