Runtime: Standard-Hashcode für Struktur mit Double- oder Float-Feld ist falsch

Erstellt am 24. Feb. 2018  ·  3Kommentare  ·  Quelle: dotnet/runtime

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");
    }

}

Hilfreichster Kommentar

Die Standardimplementierung GetHashCode für Strukturen hätte throw new NotSupportedException("Tomato!"); sein sollen :grin:

Alle 3 Kommentare

Die Standardimplementierung GetHashCode für Strukturen hätte throw new NotSupportedException("Tomato!"); sein sollen :grin:

@jkotas Wie wird die Portierung mindestens des object -Feldteils des Fixes auf eine Patch-Version angefordert? Angesichts der von Kunden gemeldeten Downstream-Fehler wie aspnet/Mvc#7673 scheinen wir dies zumindest in 2.0.x zu benötigen.

/cc @davidfowl @Eilon @Petermarcu

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen