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: build failure passing empty struct to exported Go function #42495

Closed
aclements opened this issue Nov 10, 2020 · 1 comment
Closed

cmd/cgo: build failure passing empty struct to exported Go function #42495

aclements opened this issue Nov 10, 2020 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@aclements
Copy link
Member

aclements commented Nov 10, 2020

What version of Go are you using (go version)?

$ go version
go version devel +8f2db14cd3 Tue Nov 10 18:42:47 2020 +0000 linux/amd64

Does this issue reproduce with the latest release?

No. It was introduced in CL 258938.

What did you do?

Build the following:

package p

// typedef struct { } T;
import "C"

//export F
func F(C.T) {}

(There are other types for which the failure is the same, such as struct { int x[0]; }.)

What did you expect to see?

Successful build.

What did you see instead?

_cgo_export.c: In function ‘F’:
_cgo_export.c:175:58: error: excess elements in struct initializer [-Werror]
  175 |  } __attribute__((__packed__, __gcc_struct__)) _cgo_a = {0};
      |                                                          ^
_cgo_export.c:175:58: note: (near initialization for ‘_cgo_a.p0’)

Thanks to @cherrymui for tracking this down and creating the reproducer.

@aclements aclements added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 10, 2020
@aclements aclements added this to the Go1.16 milestone Nov 10, 2020
@aclements aclements self-assigned this Nov 10, 2020
@gopherbot
Copy link

Change https://golang.org/cl/269337 mentions this issue: cmd/cgo: fix initialization of empty argument types

@golang golang locked and limited conversation to collaborators Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants