-
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: cgo error in generated wrappers points at unrelated source line #15836
Comments
Note that the line is not being printed by any Go tool. It's being printed by the C compiler. I don't know why whether the line is printed or not changed from Go 1.6 to tip; using |
I don't know if error reporting for cgo code is supposed to be accurate when printing line numbers, so I'm not sure if this a bug or not; but right now we are printing completely bogus information, and it's rather confusing (even more confusing on tip, with a random line of code appearing in the error message). More info about my env below. Go 1.6:
tip:
the c compiler:
|
It seems like we must be passing the wrong line numbers to gcc; since gcc is printing errors in "test.go" and not in the generated C file, that means we're already providing line number info to gcc. Docs at https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html for how the line control directives are supposed to be formatted. |
The line number is not really interesting here. The error is being reported in generated code, specifically the code that Go calls to wrap C's mpfr_get_prec. Maybe we should emit a #line that sets the file name to something like "". Filed #17537 for the more serious problem that somehow mpfr_get_prec's wrapper is not being generated correctly. |
CL https://golang.org/cl/32613 mentions this issue. |
go version devel +095fbdc Wed May 25 16:49:02 2016 +0000 linux/amd64
The following program (sorry about the
mpfr.h
dependency, I wasn't able to reproduce it with a custom.h
file):gives, on tip, an error that points to a bogus line in the source file. With tip:
with go1.6:
go1.6 is wrong too (it points to line 41), but at least it doesn't print it.
The text was updated successfully, but these errors were encountered: