case OINDEX:
if(!isfixedarray(n->left->type))
racewalknode(&n->left, init, 0, 0);
+ else if(!islvalue(n->left)) {
+ // index of unaddressable array, like Map[k][i].
+ racewalknode(&n->left, init, wr, 0);
+ racewalknode(&n->right, init, 0, 0);
+ goto ret;
+ }
racewalknode(&n->right, init, 0, 0);
if(n->left->type->etype != TSTRING)
callinstr(&n, init, wr, skip);
int class, res, hascalls;
n = *np;
- //print("callinstr for %+N [ %O ] etype=%d class=%d\n",
+ //print("callinstr for %+N [ %O ] etype=%E class=%d\n",
// n, n->op, n->type ? n->type->etype : -1, n->class);
if(skip || n->type == T || n->type->etype >= TIDEAL)
<-ch
}
+func TestRaceMapRWArray(t *testing.T) {
+ // Check instrumentation of unaddressable arrays (issue 4578).
+ m := make(map[int][2]int)
+ ch := make(chan bool, 1)
+ go func() {
+ _ = m[1][1]
+ ch <- true
+ }()
+ m[2] = [2]int{1, 2}
+ <-ch
+}
+
func TestNoRaceMapRR(t *testing.T) {
m := make(map[int]int)
ch := make(chan bool, 1)