From 804a43ca76a00c207a39d2846e3fe754d761ca2e Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Tue, 18 Sep 2012 17:40:53 +0200 Subject: [PATCH] cmd/gc: fix double evaluation in interface comparison During interface compare, the operands will be evaluated twice. The operands might include function calls for conversion, so make them cheap before comparing them. R=rsc CC=golang-dev https://golang.org/cl/6498133 --- src/cmd/gc/walk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 935fa6d65d7..c6b7e4278f7 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -1194,6 +1194,9 @@ walkexpr(Node **np, NodeList **init) fn = syslook("efaceeq", 1); else fn = syslook("ifaceeq", 1); + + n->right = cheapexpr(n->right, init); + n->left = cheapexpr(n->left, init); argtype(fn, n->right->type); argtype(fn, n->left->type); r = mkcall1(fn, n->type, init, n->left, n->right);