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: erroneously allows methods declared on C types #39205

Open
mdempsky opened this issue May 21, 2020 · 0 comments
Open

cmd/cgo: erroneously allows methods declared on C types #39205

mdempsky opened this issue May 21, 2020 · 0 comments
Labels

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 21, 2020

As reported at #35721 (comment), this code currently builds:

package p

import "C"

func (C.int) m() {}

This is because cmd/cgo rewrites C.int into _Ctype_int, which is a valid type to declare as a receiver parameter. However, this violates the abstraction of treating "C" as a separate package, as you can't normally declare methods on types imported from other packages.

Fixing this probably just amounts to having cmd/cgo reject C.foo identifiers within receiver parameter types, but this also risks breaking existing code that relies on this.

/cc @ianlancetaylor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.