mirror of
https://github.com/golang/go
synced 2024-11-11 23:20:24 -07:00
reflect: fix struct size calculation to include terminal padding
LGTM=r R=r CC=golang-codereviews https://golang.org/cl/160920045
This commit is contained in:
parent
68521aa6a8
commit
4e1d196543
@ -2678,6 +2678,26 @@ func TestFuncArg(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStructArg(t *testing.T) {
|
||||
type padded struct {
|
||||
B string
|
||||
C int32
|
||||
}
|
||||
var (
|
||||
gotA padded
|
||||
gotB uint32
|
||||
wantA = padded{"3", 4}
|
||||
wantB = uint32(5)
|
||||
)
|
||||
f := func(a padded, b uint32) {
|
||||
gotA, gotB = a, b
|
||||
}
|
||||
ValueOf(f).Call([]Value{ValueOf(wantA), ValueOf(wantB)})
|
||||
if gotA != wantA || gotB != wantB {
|
||||
t.Errorf("function called with (%v, %v), want (%v, %v)", gotA, gotB, wantA, wantB)
|
||||
}
|
||||
}
|
||||
|
||||
var tagGetTests = []struct {
|
||||
Tag StructTag
|
||||
Key string
|
||||
|
@ -1544,6 +1544,7 @@ func (gc *gcProg) appendProg(t *rtype) {
|
||||
for i := 0; i < c; i++ {
|
||||
gc.appendProg(t.Field(i).Type.common())
|
||||
}
|
||||
gc.align(uintptr(t.align))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user