Skip to content

Commit

Permalink
cmd/compile: fix compilation of math.Sqrt when used as a statement
Browse files Browse the repository at this point in the history
Fixes #16804

Change-Id: I669c2c24d3135cd35e15a464894ac66945847d0c
Reviewed-on: https://go-review.googlesource.com/27437
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
martisch committed Aug 21, 2016
1 parent 2f783c3 commit 6a393dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cmd/compile/internal/gc/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
16 changes: 16 additions & 0 deletions test/fixedbugs/issue16804.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 6a393dc

Please sign in to comment.