-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reflect.Copy
Incorrect When Source is Array of Len > 8
#4554
Comments
It seems that both (I'm not sure why the >64 bit size is relevant, though, since the field is either a pointer to data or a pointer to a pointer to data). |
The func ValueOf(i interface{}) Value {
typecode, value := decomposeInterface(i)
return Value{
typecode: (*rawType)(typecode),
value: value,
flags: valueFlagExported,
}
} |
Perhaps a solution would be this? diff --git a/src/reflect/value.go b/src/reflect/value.go
index d1f8cb2f..df0031b9 100644
--- a/src/reflect/value.go
+++ b/src/reflect/value.go
@@ -72,11 +72,15 @@ func decomposeInterface(i interface{}) (unsafe.Pointer, unsafe.Pointer)
func ValueOf(i interface{}) Value {
typecode, value := decomposeInterface(i)
- return Value{
+ v := Value{
typecode: (*rawType)(typecode),
value: value,
flags: valueFlagExported,
}
+ if v.typecode.Kind() == Array && v.typecode.Size() > unsafe.Sizeof(uintptr(0)) {
+ v.flags |= valueFlagIndirect
+ }
+ return v
}
func (v Value) Interface() interface{} { |
Tested from
dev
. Minimal reproduction:Result:
Not shown in the reproduction: a
[8]byte
array works fine, so the issue seems to only be for lengths > 8.The text was updated successfully, but these errors were encountered: