Repository: go
Issue: cmd/compile: error line number reported is incorrect if it appears after line 0xFFFFF
Labels: NeedsInvestigation,compiler/runtime

<!--
Please answer these questions before submitting your issue. Thanks!
For questions please use one of our forums: https://github.com/golang/go/wiki/Questions
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.13.7 linux/amd64
</pre>

### Does this issue reproduce with the latest release?

Yes.

### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/icza/.cache/go-build"
GOENV="/home/icza/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="xxx"
GONOSUMDB="xxx"
GOOS="linux"
GOPATH="/home/icza/gows"
GOPRIVATE="xxx"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build104015454=/tmp/go-build -gno-record-gcc-switches"
</pre></details>

### What did you do?

Create a valid `.go` source file that has more than `1048574` lines (`0xFFFFF`). And add some "garbage" to the end of it to make it invalid, to make compilation fail. Attempting to build it (`go build big.go`) or run it (`go run big.go`) the go tool detects the error and displays an error message where the line number is capped at `1048574` improperly, e.g.:

    ./big.go:1048574:2: syntax error: unexpected invalid after top level declaration

Here's a simple Go app that creates a `big.go` file that has approximately twice as many rows (it has a raw string literal that has 2*0xFFFFF empty lines):

```
package main

import (
	"bytes"
	"io/ioutil"
	"strings"
)

func main() {
	src := &bytes.Buffer{}
	src.WriteString(`package main
func main() { println(len(s)) }
const s=`)
	src.WriteString("`")
	src.WriteString(strings.Repeat("\n", 2*0xFFFFF))
	src.WriteString("`")

	// This is the garbage to make compilation fail:
	src.WriteString("invalid")

	if err := ioutil.WriteFile("big.go", src.Bytes(), 0666); err != nil {
		panic(err)
	}
}

```

If we decrease the generated number of lines, e.g.:

	src.WriteString(strings.Repeat("\n", 10_000))

We get the proper line number (`10003`):

    ./big.go:10003:2: syntax error: unexpected invalid after top level declaration

### What did you expect to see?

I expected the proper line number to be printed where the error is detected (`2*0xFFFFFF+3 = 2097153`):

    ./big.go:2097153:2: syntax error: unexpected invalid after top level declaration


### What did you see instead?

The displayed error line number is improperly capped at `1048574`:

    ./big.go:1048574:2: syntax error: unexpected invalid after top level declaration


**Note:** This issue was reported on StackOverflow: https://stackoverflow.com/questions/59951140/go-compiler-error-line-number-is-incorrect