Commit e56dc996 authored by Russ Cox's avatar Russ Cox

cmd/gc: fix handling of for post-condition in -race mode

Fixes #8102.

LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/100870046
parent 19c8f67e
......@@ -182,7 +182,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
// x, y := f() becomes BLOCK{CALL f, AS x [SP+0], AS y [SP+n]}
// We don't want to instrument between the statements because it will
// smash the results.
racewalknode(&n->list->n, &n->ninit, 0, 0);
racewalknode(&n->list->n, &n->list->n->ninit, 0, 0);
fini = nil;
racewalklist(n->list->next, &fini);
n->list = concat(n->list, fini);
......
......@@ -155,3 +155,18 @@ func runTests() ([]byte, error) {
cmd.Env = append(cmd.Env, `GORACE="suppress_equal_stacks=0 suppress_equal_addresses=0 exitcode=0"`)
return cmd.CombinedOutput()
}
func TestIssue8102(t *testing.T) {
// If this compiles with -race, the test passes.
type S struct {
x interface{}
i int
}
c := make(chan int)
a := [2]*int{}
for ; ; c <- *a[S{}.i] {
if t != nil {
break
}
}
}
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