1
0
mirror of https://github.com/golang/go synced 2024-11-21 14:34:41 -07:00

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
This commit is contained in:
Daniel Morsing 2012-09-18 17:40:53 +02:00
parent 648c9eb0b5
commit 804a43ca76

View File

@ -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);