]> Cypherpunks repositories - gostls13.git/commit
reflect: Fix Convert to add indir bit when the value is actually a
authorTodd Wang <toddwang@gmail.com>
Wed, 21 Aug 2013 04:41:55 +0000 (14:41 +1000)
committerRob Pike <r@golang.org>
Wed, 21 Aug 2013 04:41:55 +0000 (14:41 +1000)
commit0e73497a4ba97048222ae262f7b5a40c281af0b6
tree732c0a7e472f692dbb35e5e84586bf697655cf09
parentefdbf0811c86f32eb029ff3f2affdf63337ed2fa
reflect: Fix Convert to add indir bit when the value is actually a
pointer.  An example that triggers the bad behavior on a 64bit
machine http://play.golang.org/p/GrNFakAYLN
        rv1 := reflect.ValueOf(complex128(0))
        rt := rv1.Type()
        rv2 := rv1.Convert(rt)
        rv3 := reflect.New(rt).Elem()
        rv3.Set(rv2)

Running the code fails with the following:
        panic: reflect: internal error: storeIword of 16-byte value

I've tested on a 64bit machine and verified this fixes the panic.  I
haven't tested on a 32bit machine so I haven't verified the other
cases, but they follow logically.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/12805045
src/pkg/reflect/all_test.go
src/pkg/reflect/value.go