mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
1 changed files with 2 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue