]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "reflect: when Converting between float32s, don't lose signal NaNs"
authorKeith Randall <khr@golang.org>
Tue, 25 Feb 2020 05:57:22 +0000 (05:57 +0000)
committerKeith Randall <khr@golang.org>
Tue, 25 Feb 2020 06:22:21 +0000 (06:22 +0000)
This reverts commit 7485050c0f55492c0fdfc41f7564f3da37a1a308.

Reason for revert: Breaking some builders (387, mips, mips64)

Change-Id: I33e5125b7a9a96b55bc5e71880fca4ee30d226a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/220695
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/reflect/all_test.go
src/reflect/value.go

index 496d0e9241a1693d405e42393c7c7edcdaa561b0..00c18104eb7dfa5c0cf3900d64ddaeca5eac9dfc 100644 (file)
@@ -4163,17 +4163,6 @@ func TestConvert(t *testing.T) {
        }
 }
 
-func TestConvertNaNs(t *testing.T) {
-       const snan uint32 = 0x7f800001
-       type myFloat32 float32
-       x := V(myFloat32(math.Float32frombits(snan)))
-       y := x.Convert(TypeOf(float32(0)))
-       z := y.Interface().(float32)
-       if got := math.Float32bits(z); got != snan {
-               t.Errorf("signaling nan conversion got %x, want %x", got, snan)
-       }
-}
-
 type ComparableStruct struct {
        X int
 }
index d8b5d11cbdcf67fd7c827d2d21bdf7c0bed0e6b7..0f5e0836634633999221d71943ceeab8f3ec014a 100644 (file)
@@ -2541,14 +2541,6 @@ func makeFloat(f flag, v float64, t Type) Value {
        return Value{typ, ptr, f | flagIndir | flag(typ.Kind())}
 }
 
-// makeFloat returns a Value of type t equal to v, where t is a float32 type.
-func makeFloat32(f flag, v float32, t Type) Value {
-       typ := t.common()
-       ptr := unsafe_New(typ)
-       *(*float32)(ptr) = v
-       return Value{typ, ptr, f | flagIndir | flag(typ.Kind())}
-}
-
 // makeComplex returns a Value of type t equal to v (possibly truncated to complex64),
 // where t is a complex64 or complex128 type.
 func makeComplex(f flag, v complex128, t Type) Value {
@@ -2621,12 +2613,6 @@ func cvtUintFloat(v Value, t Type) Value {
 
 // convertOp: floatXX -> floatXX
 func cvtFloat(v Value, t Type) Value {
-       if v.Type().Kind() == Float32 && t.Kind() == Float32 {
-               // Don't do any conversion if both types have underlying type float32.
-               // This avoids converting to float64 and back, which will
-               // convert a signaling NaN to a quiet NaN. See issue 36400.
-               return makeFloat32(v.flag.ro(), *(*float32)(v.ptr), t)
-       }
        return makeFloat(v.flag.ro(), v.Float(), t)
 }