compiler: nil-checked pointers and index expressions can trap
authorIan Lance Taylor <iant@golang.org>
Wed, 23 Dec 2020 21:54:35 +0000 (13:54 -0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 23 Dec 2020 22:08:52 +0000 (14:08 -0800)
commit3932785450fb74a886b8eb3d6f889de9766b7e8e
tree88f09a63109a96ea57a7bdf1cf6990f7ad68c3b8
parent0a541e746c71fe21eb72bae61a9ead541ed7e98d
compiler: nil-checked pointers and index expressions can trap

The compiler was treating indirections through pointers that had been
explicitly checked against nil and slice and string index expressions
as non-trapping memory references.  That is true for ordinary Go
programs, but it isn't true if the programs construct their own memory
addresses.  In particular it isn't true for the kinds of programs that
want to use runtime.SetPanicOnFault.

The effect of this will be slightly larger binaries, due to additional
exception information, and perhaps slightly less optimization.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/279960
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc