Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: incomplete typedef can cause "inconsistent definitions" error #26430

Closed
ianlancetaylor opened this issue Jul 18, 2018 · 2 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@ianlancetaylor
Copy link
Contributor

Using an incomplete typedef seems to sometimes cause an "inconsistent definitions" error from cgo.

GOPATH/src/a/a.go:

package a

// typedef struct S ST;
// ST* M() {}
import "C"

func F1() {
	C.M()
}

GOPATH/src/a/b.go:

package a

// typedef struct S ST;
// struct S { int f; };
import "C"

func F2(p *C.ST) {
	p.f = 1
}
> go build a
# a
inconsistent definitions for C.ST
> ~/go1.10/bin/go build a
> # no error

Reverting https://golang.org/cl/123177 (b888a62) fixes cgo on tip. CC @randall77

@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Jul 18, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Jul 18, 2018
@gopherbot
Copy link

Change https://golang.org/cl/124575 mentions this issue: cmd/cgo: don't report inconsistency error for incomplete typedef

@gopherbot
Copy link

Change https://golang.org/cl/128155 mentions this issue: [release-branch.go1.10] cmd/cgo: don't report inconsistency error for incomplete typedef

gopherbot pushed a commit that referenced this issue Aug 7, 2018
… incomplete typedef

In CLs 122575 and 123177 the cgo tool started explicitly looking up
typedefs. When there are two Go files using import "C", and the first
one has an incomplete typedef and the second one has a complete
version of the same typedef, then we will now record a version of the
first typedef which will not match the recorded version of the second
typedef, producing an "inconsistent definitions" error. Fix this by
silently merging incomplete typedefs with complete ones.

Fixes #26430

Change-Id: I9e629228783b866dd29b5c3a31acd48f6e410a2d
Reviewed-on: https://go-review.googlesource.com/124575
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit a371bc2)
Reviewed-on: https://go-review.googlesource.com/128155
@golang golang locked and limited conversation to collaborators Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

2 participants