-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: don't accept mangled C names in Cgo programs #28721
Comments
#24941 |
What happens when you do this instead?
|
@AlexRouSg Building succeeds. |
Any particular reason you're using |
A third-party package I used is like this. Debugging finds this. |
cc @eliasnaur |
I believe the bug is that Go accepts the program, but shouldn't, while go/types correctly rejects the program. _Ctype_struct_a is not a defined type, and the program only builds because of the way Cgo mangles C type names. @ianlancetaylor do you agree? If so, should Go reject such programs? I believe the correct fix is to change to program to use C.a instead, as suggested by AlexRouSg. |
Ian, I changed the title to match what I believe is the root cause. Feel free to throw it back to me if I'm mistaken. |
Sorry, somehow I missed this earlier. I agree: cgo should reject the attempt to use |
Change https://golang.org/cl/152657 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
$
gomobile bind test
What did you expect to see?
Building succeeds.
What did you see instead?
gomobile: /Users/zsm/go/bin/gobind -lang=go,java -outdir=/var/folders/6v/7stmg2756wlfk9c_qnv1hnbm0000gn/T/gomobile-work-058021600 test failed: exit status 1
type-checking package "test" failed (/Users/zsm/go/src/test/main.go:15:5: undeclared name: _Ctype_struct_a)
The text was updated successfully, but these errors were encountered: