diff mbox

libgo patch committed: Fix bug comparing struct field types

Message ID mcrsj8h8apo.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Nov. 10, 2012, 8:27 p.m. UTC
This patch fixes a bug comparing struct field types in the reflect
package.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline and 4.7 branch.

Ian
diff mbox

Patch

diff -r 8b1f2a35ded1 libgo/go/reflect/type.go
--- a/libgo/go/reflect/type.go	Tue Nov 06 10:44:51 2012 -0800
+++ b/libgo/go/reflect/type.go	Sat Nov 10 12:20:00 2012 -0800
@@ -1309,8 +1309,19 @@ 
 		for i := range t.fields {
 			tf := &t.fields[i]
 			vf := &v.fields[i]
-			if tf.name != vf.name || tf.pkgPath != vf.pkgPath ||
-				tf.typ != vf.typ || tf.tag != vf.tag || tf.offset != vf.offset {
+			if tf.name != vf.name && (tf.name == nil || vf.name == nil || *tf.name != *vf.name) {
+				return false
+			}
+			if tf.pkgPath != vf.pkgPath && (tf.pkgPath == nil || vf.pkgPath == nil || *tf.pkgPath != *vf.pkgPath) {
+				return false
+			}
+			if tf.typ != vf.typ {
+				return false
+			}
+			if tf.tag != vf.tag && (tf.tag == nil || vf.tag == nil || *tf.tag != *vf.tag) {
+				return false
+			}
+			if tf.offset != vf.offset {
 				return false
 			}
 		}