Runtime: 具有 double 或 float 字段的结构的默认哈希码是错误的

创建于 2018-02-24  ·  3评论  ·  资料来源: dotnet/runtime

扬声器:

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

}

最有用的评论

结构的默认GetHashCode实现应该是throw new NotSupportedException("Tomato!"); :grin:

所有3条评论

结构的默认GetHashCode实现应该是throw new NotSupportedException("Tomato!"); :grin:

@jkotas请求至少将修复的object字段部分移植到补丁版本的过程是什么? 鉴于客户报告的下游错误(例如 aspnet/Mvc#7673),似乎我们至少在 2.0.x 中需要这个。

/cc @davidfowl @Eilon @Petermarcu

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

ilmax picture ilmax  ·  3评论

omariom picture omariom  ·  3评论

chunseoklee picture chunseoklee  ·  3评论

jzabroski picture jzabroski  ·  3评论

noahfalk picture noahfalk  ·  3评论