From 83e288f3dbfdc83e4a016c60d54f928f69608d9a Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 10 Apr 2020 09:43:22 -0700 Subject: cmd/compile: prevent constant folding of +/- when result is NaN Missed as part of CL 221790. It isn't just * and / that can make NaNs. Update #36400 Fixes #38359 Change-Id: I3fa562f772fe03b510793a6dc0cf6189c0c3e652 Reviewed-on: https://go-review.googlesource.com/c/go/+/227860 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: Alberto Donizetti Reviewed-by: Cuong Manh Le --- test/fixedbugs/issue38359.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/fixedbugs/issue38359.go (limited to 'test') diff --git a/test/fixedbugs/issue38359.go b/test/fixedbugs/issue38359.go new file mode 100644 index 0000000000..a7550c7b2c --- /dev/null +++ b/test/fixedbugs/issue38359.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Make sure NaN-NaN compiles correctly. + +package p + +func f() { + var st struct { + f float64 + _, _ string + } + + f := 1e308 + st.f = 2*f - 2*f +} -- cgit v1.2.1