This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libgo patch committed: Fix reflect bug in method calls

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.


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)
+		}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]