This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
libgo patch committed: Fix reflect bug in method calls
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 17 Sep 2013 15:12:17 -0700
- Subject: libgo patch committed: Fix reflect bug in method calls
- Authentication-results: sourceware.org; auth=none
This patch to libgo fixes a bug when calling a method when the
reflect.Value object holds a pointer to the actual value. The code was
calling iword which tests v.kind, but for a method value that is always
Func. This fixes the code to implement iword directly using
v.typ.Kind(). Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline and 4.8 branch.
I added a test to the reflect testsuite in the master sources, and it
will be imported into the gccgo sources in due course.
Ian
Index: libgo/go/reflect/value.go
===================================================================
--- libgo/go/reflect/value.go (revision 202233)
+++ libgo/go/reflect/value.go (working copy)
@@ -611,7 +611,13 @@ func methodReceiver(op string, v Value,
}
fn = unsafe.Pointer(&m.tfn)
t = m.mtyp
- rcvr = v.iword()
+ // Can't call iword here, because it checks v.kind,
+ // and that is always Func.
+ if v.flag&flagIndir != 0 && (v.typ.Kind() == Ptr || v.typ.Kind() == UnsafePointer) {
+ rcvr = loadIword(v.val, v.typ.size)
+ } else {
+ rcvr = iword(v.val)
+ }
}
return
}