-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/cgo: does not correctly read DWARF data for unsigned types #39136
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
Comments
/cc: @ianlancetaylor |
I can't run your test case on GNU/Linux.
Can you shrink this down to a smaller more portable test case? Thanks. |
@ianlancetaylor yeah, this works with
|
Although perhaps tangential, I'd posit that this is also a bug:
|
Thanks. If it's a bug, it's a different bug. |
Ok. For more context, the original bug only occurs when the (top level)
|
Minimal reproducer:
but
There are two related issues here:
The second issue is addressed by changing The first issue seems to be because gcc rejects this code, but clang accepts it:
I'm not sure how best to deal with this. One possibility might be for cgo to emit code using -- Finally, I'll note while looking into this, I also observed that gcc and clang differently handle
In particular, gcc results in C.X being declared as a negative constant in Go, while clang leads to a positive constant. Casually looking at the |
Thanks for the investigation, reproducers, and debugging @mdempsky @ianlancetaylor, and thanks for reporting the @elagergren-spideroak! I am punting this issue to Go1.17 as it is quite late in the Go1.16 cycle, but perhaps for Go1.17. Kindly also cc-ing @hajimehoshi, if you might be interested. |
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?
https://play.golang.org/p/73rgY0pPok8
What did you expect to see?
The values for all types be
0xa4a4a4...
(i.e., unsigned integers).What did you see instead?
Them converted to signed integers.
This is because
go/src/cmd/cgo/gcc.go
Line 618 in afd477f
*dwarf.UintType
when some types are, e.g., a*QualType
wrapping a*TypedefType
, which then contains a*UintType
.This patch fixes it, at least on macOS.
The text was updated successfully, but these errors were encountered: