mirror of
https://github.com/golang/go
synced 2024-11-26 01:57:56 -07:00
Bug in reflect found by gri. Structs in 6g have a minimum alignment.
iant: will this be ok in gccgo? R=rsc DELTA=9 (8 added, 0 deleted, 1 changed) OCL=28059 CL=28062
This commit is contained in:
parent
49eb63cfd5
commit
c0b8b969ae
@ -80,9 +80,13 @@ type allTypes struct {
|
||||
xuintptr uintptr;
|
||||
}
|
||||
|
||||
var x allTypes
|
||||
var (
|
||||
x allTypes;
|
||||
minStruct struct { uint8 };
|
||||
)
|
||||
|
||||
const (
|
||||
minStructAlign = unsafe.Sizeof(minStruct) - 1;
|
||||
ptrsize = unsafe.Sizeof(&x);
|
||||
interfacesize = unsafe.Sizeof(x.xinterface);
|
||||
)
|
||||
@ -394,6 +398,10 @@ func (t *structTypeStruct) Size() int {
|
||||
size += elemsize;
|
||||
}
|
||||
if (structalign > 0) {
|
||||
// 6g etc. always aligns structs to a minimum size, typically int64
|
||||
if structalign < minStructAlign {
|
||||
structalign = minStructAlign
|
||||
}
|
||||
// TODO: In the PPC64 ELF ABI, floating point fields
|
||||
// in a struct are aligned to a 4-byte boundary, but
|
||||
// if the first field in the struct is a 64-bit float,
|
||||
|
Loading…
Reference in New Issue
Block a user