diff --git a/src/cmd/8g/cgen.c b/src/cmd/8g/cgen.c index d626c2eb02..5988a4328c 100644 --- a/src/cmd/8g/cgen.c +++ b/src/cmd/8g/cgen.c @@ -347,8 +347,11 @@ cgen(Node *n, Node *res) if(istype(nl->type, TCHAN)) { // chan has cap in the second 32-bit word. // a zero pointer means zero length - regalloc(&n1, types[tptr], res); + tempname(&n1, types[tptr]); cgen(nl, &n1); + regalloc(&n2, types[tptr], N); + gmove(&n1, &n2); + n1 = n2; nodconst(&n2, types[tptr], 0); gins(optoas(OCMP, types[tptr]), &n1, &n2); diff --git a/test/torture.go b/test/torture.go index bbf6d347d9..197b481e66 100644 --- a/test/torture.go +++ b/test/torture.go @@ -337,3 +337,10 @@ func ChainDivConst(a int) int { func ChainMulBytes(a, b, c byte) byte { return a*(a*(a*(a*(a*(a*(a*(a*(a*b+c)+c)+c)+c)+c)+c)+c)+c) + c } + +func ChainCap() { + select { + case <-make(chan int, cap(make(chan int, cap(make(chan int, cap(make(chan int, cap(make(chan int))))))))): + default: + } +}