Commit f934bb8e authored by Rob Pike's avatar Rob Pike

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
parent 3730ddcb
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment