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: wrong line number in error message #50133

Open
go101 opened this issue Dec 13, 2021 · 1 comment
Open

cmd/compile: wrong line number in error message #50133

go101 opened this issue Dec 13, 2021 · 1 comment

Comments

@go101
Copy link

@go101 go101 commented Dec 13, 2021

What version of Go are you using (go version)?

$ go version
go version go1.17.5 linux/amd64
go version devel go1.18-9bfe09d78b Mon Dec 13 06:35:06 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

const N = 2000000000

var x [N+1]byte

var y *[N+1]byte

func main() {
	var a [N+1]byte // okay
	y = &a // main.go:11:4: main.x: symbol too large (2000000001 bytes > 2000000000 bytes)
}

What did you expect to see?

main.go:5:5: main.x: symbol too large (2000000001 bytes > 2000000000 bytes)

What did you see instead?

main.go:11:4: main.x: symbol too large (2000000001 bytes > 2000000000 bytes)
@cherrymui cherrymui added this to the Backlog milestone Dec 13, 2021
@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Dec 13, 2021

This error is from the object file writer, https://cs.opensource.google/go/go/+/master:src/cmd/internal/obj/objfile.go;l=371 , which is called from https://cs.opensource.google/go/go/+/master:src/cmd/compile/internal/gc/obj.go;l=182
The object file writer does not have information about the line number, and LSym doesn't carry a line number either. The line number in the message is from base.Pos, whatever that is last updated (ctxt.Diag calls base.Errorf).

Maybe we could set base.Pos to NoXPos when writing object files, so it will not print a misleading line number. Or we could perhaps move the "symbol too large" detection earlier into the compiler (but there may be other errors emitted by the object file writer which may have the same problem).

cc @griesemer @mdempsky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants