1
0
mirror of https://github.com/golang/go synced 2024-10-02 04:28:33 -06:00

cmd/compile: compute number of arguments correctly

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>
This commit is contained in:
David Crawshaw 2016-03-11 17:49:07 -05:00
parent ae00df128d
commit 7c546566c3
2 changed files with 12 additions and 1 deletions

View File

@ -1068,7 +1068,7 @@ ok:
ot += 4 // align for *rtype ot += 4 // align for *rtype
} }
dataAdd := (inCount + outCount) * Widthptr dataAdd := (inCount + t.Outtuple) * Widthptr
ot = dextratype(s, ot, t, dataAdd) ot = dextratype(s, ot, t, dataAdd)
// Array of rtype pointers follows funcType. // Array of rtype pointers follows funcType.

View 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) { func TestPtrTo(t *testing.T) {
var i int var i int