mirror of
https://github.com/golang/go
synced 2024-11-26 14:08:37 -07:00
cgo: set alignment to 1 for unions and classes; avoids crash from divide-by-zero
Fixes #4114. R=golang-dev, iant, rsc, iant, devon.odell CC=golang-dev https://golang.org/cl/6553050
This commit is contained in:
parent
3730ddcbd8
commit
f934bb8eba
@ -1190,11 +1190,12 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
|
||||
t.Go = name // publish before recursive calls
|
||||
goIdent[name.Name] = name
|
||||
switch dt.Kind {
|
||||
case "union", "class":
|
||||
case "class", "union":
|
||||
t.Go = c.Opaque(t.Size)
|
||||
if t.C.Empty() {
|
||||
t.C.Set("typeof(unsigned char[%d])", t.Size)
|
||||
}
|
||||
t.Align = 1 // TODO: should probably base this on field alignment.
|
||||
typedef[name.Name] = t
|
||||
case "struct":
|
||||
g, csyntax, align := c.Struct(dt, pos)
|
||||
|
Loading…
Reference in New Issue
Block a user