Commit 51266761 authored by Russ Cox's avatar Russ Cox

cmd/gc: fix divide by zero error in compiler

Fixes #6399.

R=ken2
CC=golang-dev
https://golang.org/cl/13253055
parent a70cbf13
......@@ -1295,7 +1295,7 @@ walkexpr(Node **np, NodeList **init)
t = n->type;
if(n->esc == EscNone
&& smallintconst(l) && smallintconst(r)
&& mpgetfix(r->val.u.xval) < (1ULL<<16) / t->type->width) {
&& (t->type->width == 0 || mpgetfix(r->val.u.xval) < (1ULL<<16) / t->type->width)) {
// var arr [r]T
// n = arr[:l]
t = aindex(r, t->type); // [r]T
......
// compile
package main
type Foo interface {
Print()
}
type Bar struct{}
func (b Bar) Print() {}
func main() {
b := make([]Bar, 20)
f := make([]Foo, 20)
for i := range f {
f[i] = b[i]
}
T(f)
_ = make([]struct{}, 1)
}
func T(f []Foo) {
for i := range f {
f[i].Print()
}
}
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