]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: compute number of arguments correctly
authorDavid Crawshaw <crawshaw@golang.org>
Fri, 11 Mar 2016 22:49:07 +0000 (17:49 -0500)
committerDavid Crawshaw <crawshaw@golang.org>
Sat, 12 Mar 2016 01:23:25 +0000 (01:23 +0000)
The outCount value includes a flag bit for dotdotdot.

If we have this count incorrect, then the offset for the
methodset *rtype are in the wrong place.

Fixes #14783

Change-Id: If5acb16af08d4ffe36c8c9ee389c32f2712ce757
Reviewed-on: https://go-review.googlesource.com/20566
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/reflect.go
src/reflect/all_test.go

index cd39969258f51c553dd9249d2980819167739dcd..5ca292c39e368cafd1bc42a892a0a43bdd344413 100644 (file)
@@ -1068,7 +1068,7 @@ ok:
                        ot += 4 // align for *rtype
                }
 
-               dataAdd := (inCount + outCount) * Widthptr
+               dataAdd := (inCount + t.Outtuple) * Widthptr
                ot = dextratype(s, ot, t, dataAdd)
 
                // Array of rtype pointers follows funcType.
index 352b2046e7c0811cc84ec4b8e36b6baee41a5c9f..32dd782c3c03f606a53b9a03c2afa229d748c316 100644 (file)
@@ -2410,6 +2410,17 @@ func TestEmbeddedMethods(t *testing.T) {
        }
 }
 
+type FuncDDD func(...interface{}) error
+
+func (f FuncDDD) M() {}
+
+func TestNumMethodOnDDD(t *testing.T) {
+       rv := ValueOf((FuncDDD)(nil))
+       if n := rv.NumMethod(); n != 1 {
+               t.Fatalf("NumMethod()=%d, want 1", n)
+       }
+}
+
 func TestPtrTo(t *testing.T) {
        var i int