src/cmd/cgo/gcc.go | 6 +++++- src/cmd/cgo/main.go | 1 + diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 11a5472786d761b4f4089f711793cf33eca02bfe..915ad66111b8987dad2201ff279dff8a6e716db5 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -901,7 +901,7 @@ // Use "var x T = ..." syntax to explicitly convert untyped // constants to the parameter type, to avoid a type mismatch. ptype := p.rewriteUnsafe(param.Go) - if !p.needsPointerCheck(f, param.Go, args[i]) { + if !p.needsPointerCheck(f, param.Go, args[i]) || param.BadPointer { if ptype != param.Go { needsUnsafe = true } @@ -2465,13 +2465,16 @@ if c.badPointerTypedef(dt) { // Treat this typedef as a uintptr. s := *sub s.Go = c.uintptr + s.BadPointer = true sub = &s // Make sure we update any previously computed type. if oldType := typedef[name.Name]; oldType != nil { oldType.Go = sub.Go + oldType.BadPointer = true } } t.Go = name + t.BadPointer = sub.BadPointer if unionWithPointer[sub.Go] { unionWithPointer[t.Go] = true } @@ -2481,6 +2484,7 @@ oldType := typedef[name.Name] if oldType == nil { tt := *t tt.Go = sub.Go + tt.BadPointer = sub.BadPointer typedef[name.Name] = &tt } diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go index 11aeee4aab74f661d8f3a62197c6ff5faef64ba4..5a7bb3f87bc73f7b5b0675a4fc6851313d182e9f 100644 --- a/src/cmd/cgo/main.go +++ b/src/cmd/cgo/main.go @@ -151,6 +151,7 @@ C *TypeRepr Go ast.Expr EnumValues map[string]int64 Typedef string + BadPointer bool } // A FuncType collects information about a function type in both the C and Go worlds.