-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: -godefs: incorrect output when using TAILQ_ENTRY #37479
Comments
Standalone test case: package demo
/*
typedef struct A A;
typedef struct {
struct A *next;
struct A **prev;
} N;
struct A
{
N n;
};
typedef struct B
{
A* a;
} B;
*/
import "C"
type N C.N
type A C.A
type B C.B |
This is caused by https://golang.org/cl/181857 for issue #31891. |
The I'll add that I'm honestly not sure how |
workaround golang/go#37479
CL 181857 broke the translation of certain C types when using cmd/cgo -godefs. Updates golang#31891 Fixes golang#37479 Fixes golang#37621 Change-Id: I301a749ec89585789cb0d213593bb8b7341beb88
Change https://golang.org/cl/226341 mentions this issue: |
Change https://golang.org/cl/226497 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, this issue appears since Go 1.14, but did not happen with Go 1.13.8.
What operating system and processor architecture are you using (
go env
)?I have Ubuntu 18.04 on a server with Xeon Gold 6240 CPU.
go env
OutputWhat did you do?
I am executing
go tool cgo -godefs x.go
command on the following input:What did you expect to see?
I expect to see this output. This was the output from Go 1.13.8.
What did you see instead?
I see this output instead. Notice that in
type B
, the variableA
has type*_Ctype_struct_A
, instead of the expected type*A
.Further information
It seems that this problem is correlated to
TAILQ_ENTRY
macro. Iftype A
does not contain a variable of a type defined by this macro, the problem does not occur.If I manually expand the macro into the snippet below, the problem persists.
However, if I remove
struct
like the snippet below, the problem disappears.The text was updated successfully, but these errors were encountered: