From 6a393dc64fb06ba17f737432a45c63233aa4bd3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mo=CC=88hrmann?= Date: Sun, 21 Aug 2016 09:57:01 +0200 Subject: [PATCH] cmd/compile: fix compilation of math.Sqrt when used as a statement Fixes #16804 Change-Id: I669c2c24d3135cd35e15a464894ac66945847d0c Reviewed-on: https://go-review.googlesource.com/27437 Reviewed-by: Keith Randall Reviewed-by: Josh Bleecher Snyder Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/ssa.go | 3 +++ test/fixedbugs/issue16804.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/fixedbugs/issue16804.go diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 781fe1b2d5b..304f446df1d 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -966,6 +966,9 @@ func (s *state) stmt(n *Node) { p := s.expr(n.Left) s.nilCheck(p) + case OSQRT: + s.expr(n.Left) + default: s.Unimplementedf("unhandled stmt %s", n.Op) } diff --git a/test/fixedbugs/issue16804.go b/test/fixedbugs/issue16804.go new file mode 100644 index 00000000000..46dd4a33ccb --- /dev/null +++ b/test/fixedbugs/issue16804.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2016 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. + +// Issue 16804: internal error for math.Sqrt as statement +// rather than expression + +package main + +import "math" + +func sqrt() { + math.Sqrt(2.0) +}