Commit 804a43ca authored by Daniel Morsing's avatar Daniel Morsing

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
parent 648c9eb0
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment