Repository: go
Issue: cmd/cover: lines that are unreached (due to panic() ) appear as covered by test
Labels: NeedsInvestigation,compiler/runtime

<!-- Please answer these questions before submitting your issue. Thanks! -->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.17 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ondre\AppData\Local\go-build
set GOENV=C:\Users\ondre\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\ondre\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\ondre\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\ondre\OneDrive\Desktop\workplace\mladata-bang\bang-backend\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ondre\AppData\Local\Temp\go-build1886039437=/tmp/go-build -gno-record-gcc-switches
gdb --version: GNU gdb (GDB) 7.9.1
</pre></details>

### What did you do?

<!--
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
-->

When running tests with coverage, the lines after calling a panicking function appear to be covered, even though the test could never reach them. They are not executed, just appear to be covered. This happens to every line until a branching statement is reached as can be seen when adding regular statements above the branching statement.

An example can be found at [https://github.com/mazanec202/go-wrong-panic-coverage](https://github.com/mazanec202/go-wrong-panic-coverage). In this case I had to place the panicking function to a separate package, however on my personal project was the logic complex enough not to be marked by `go vet` as unused while residing in a single package.

Using the following commands on the project, it's possible to verify the problem:
`go test -coverprofile=coverage.out`
`go tool cover -html=coverage.out`

I believe this issue could provide a false sense of safety and could therefore lead to potential security issues.

### What did you expect to see?
Only a line 16 (main.go) containing `panic.DoPanic(true)` to be marked as covered. Line 17 (main.go) containing `shouldBeZero = 1` should be marked as not covered.


### What did you see instead?
Line 17 (main.go) containing `shouldBeZero = 1` is marked as covered, even though the tests prove that the panic was executed and value of `shouldBeZero` is unchanged - `0`.