From: Daniel Morsing Date: Tue, 18 Sep 2012 15:40:53 +0000 (+0200) Subject: cmd/gc: fix double evaluation in interface comparison X-Git-Tag: go1.1rc2~2425 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=804a43ca76a00c207a39d2846e3fe754d761ca2e;p=gostls13.git 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 --- diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 935fa6d65d..c6b7e4278f 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);