mirror of
https://github.com/golang/go
synced 2024-11-25 11:57:58 -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:
parent
648c9eb0b5
commit
804a43ca76
@ -1194,6 +1194,9 @@ walkexpr(Node **np, NodeList **init)
|
|||||||
fn = syslook("efaceeq", 1);
|
fn = syslook("efaceeq", 1);
|
||||||
else
|
else
|
||||||
fn = syslook("ifaceeq", 1);
|
fn = syslook("ifaceeq", 1);
|
||||||
|
|
||||||
|
n->right = cheapexpr(n->right, init);
|
||||||
|
n->left = cheapexpr(n->left, init);
|
||||||
argtype(fn, n->right->type);
|
argtype(fn, n->right->type);
|
||||||
argtype(fn, n->left->type);
|
argtype(fn, n->left->type);
|
||||||
r = mkcall1(fn, n->type, init, n->left, n->right);
|
r = mkcall1(fn, n->type, init, n->left, n->right);
|
||||||
|
Loading…
Reference in New Issue
Block a user