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: _GoString_ is a reserved identifier #29877

Open
phst opened this issue Jan 22, 2019 · 5 comments
Open

cmd/cgo: _GoString_ is a reserved identifier #29877

phst opened this issue Jan 22, 2019 · 5 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@phst
Copy link
Contributor

phst commented Jan 22, 2019

(Removing the template since this is not really a code bug or so.)

https://golang.org/cmd/cgo/#hdr-Go_references_to_C explains that there's a type _GoString_. However, that name is reserved (see https://en.cppreference.com/w/c/language/identifier#Reserved_identifiers), and using it is technically undefined behavior. I'd suggest renaming the type to just GoString in future versions, with the old name as undocumented and deprecated alias.

@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Jan 22, 2019
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jan 22, 2019
@phst
Copy link
Contributor Author

phst commented Jan 23, 2019

This is also the case for most other Cgo names in C.

@phst
Copy link
Contributor Author

phst commented Jan 24, 2019

If you're fine with renaming all the Cgo identifiers, I can take this.

@ianlancetaylor
Copy link
Contributor

Renaming all the cgo identifiers seems likely to break existing code. I'm not sure exactly what we can do here.

@phst
Copy link
Contributor Author

phst commented Jan 27, 2019

From skimming https://golang.org/cmd/cgo/, _GoString_ and the associated functions seem to be the only documented ones. I'd suggest we rename them, but provide aliases/forwarding functions marked as deprecated. If we don't care about breakages caused by using the undocumented names, we can just rename them.

@ianlancetaylor
Copy link
Contributor

Do you happen to have a list of the undocumented names that are invalid according to the C standard?

Unfortunately history tells us that many people write code that refers to undocumented cgo names.

I'm OK with renaming GoString in the docs as long it continues to work in the code.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants