-
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: mishandles untyped constants in some cases #30527
Comments
This issue was discovered in remyoudompheng/go-liblzma@da7c45f |
This may be hard to fix. |
I wonder if it can be fixed by the following kind of patch. Let me see if it passes tests, I may submit a CL.
|
Hmmm, good idea. Let me know. Thanks. |
Change https://golang.org/cl/164897 mentions this issue: |
Change https://golang.org/cl/165748 mentions this issue: |
… constants Instead of trying to guess type of constants in the AST, which is hard, use the "var cgo%d Type = Constant" so that typechecking is left to the Go compiler. The previous code could still fail in some cases for constants imported from other modules or defined in other, non-cgo files. Fixes #30527 Change-Id: I2120cd90e90a74b9d765eeec53f6a3d2cfc1b642 Reviewed-on: https://go-review.googlesource.com/c/go/+/164897 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 711ea1e) Reviewed-on: https://go-review.googlesource.com/c/go/+/165748 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, but it does not happen with go 1.11.5
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Create a 2-file package which invokes a C function with untyped constants.
What did you expect to see?
Successful compilation (as with go1.11.5)
What did you see instead?
The error disappears if
MaxUint64
is defined in the same package, or ifz
is defined in the same file.The text was updated successfully, but these errors were encountered: