reflect: fix Zero() implementation - not every type has a

zero object allocated, so we still need to allocate a new
zero area every time.

Fixes #6876.

R=golang-dev
CC=golang-dev
https://golang.org/cl/36320043
This commit is contained in:
Keith Randall 2013-12-02 16:54:29 -08:00
parent 85138da832
commit e7d899cba5
1 changed files with 1 additions and 1 deletions

View File

@ -2175,7 +2175,7 @@ func Zero(typ Type) Value {
if t.size <= ptrSize {
return Value{t, nil, fl}
}
return Value{t, t.zero, fl | flagIndir}
return Value{t, unsafe_New(typ.(*rtype)), fl | flagIndir}
}
// New returns a Value representing a pointer to a new zero value