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/compile: incorrect line numbers for //line pragmas on Windows (cgo) #18149

Closed
griesemer opened this issue Dec 1, 2016 · 2 comments
Closed
Milestone

Comments

@griesemer
Copy link
Contributor

https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/noder.go implements //line pragma parsing now that the old lexer has been replaced.

When splitting //line filename:line into the filename and line part, noder.go looks for the first ':' to make the split: See https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/noder.go, line 1025, strings.IndexByte.

This is a problem for filenames containing ':' such as in Windows (C:foo/bar.go) - the resulting line numbers will be incorrect (but no error is reported).

The old code looked for the last ':' after "// line ". See e.g., https://github.com/golang/go/blob/adda7ad29551d0880df1805ae22401551b1fbfa8/src/cmd/compile/internal/gc/lex.go, line 961ff., the last ':' position is recorded on line 987 and then used to split the string below (line 997).

This is a regression from 1.7 and should be fixed for 1.8 (fix is trivial).

@griesemer griesemer added this to the Go1.8 milestone Dec 1, 2016
@griesemer griesemer self-assigned this Dec 1, 2016
@gopherbot
Copy link

CL https://golang.org/cl/33799 mentions this issue.

@mdempsky
Copy link
Member

mdempsky commented Dec 1, 2016

Doh, I missed that subtlety when redo'ing the pragma support. :(

@golang golang locked and limited conversation to collaborators Dec 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants