With the gc toolchain apparently var s *string _ = *s is enough to panic with a nil pointer dereference. The gccgo compiler will simply discard the dereference, which I think is a reasonable and acceptable optimization. Change the tests to use an exported variable instead. The tests are not currently run, but they will be with a later patch to gotools.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 249561) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -b5c9fe259ec43f8079581c3bea0f1d12d85213a7 +8804c912363320e0c229c5a471fb6f4b9e5965e6 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/testdata/testprog/crash.go =================================================================== --- libgo/go/runtime/testdata/testprog/crash.go (revision 249205) +++ libgo/go/runtime/testdata/testprog/crash.go (working copy) @@ -13,6 +13,8 @@ func init() { register("Crash", Crash) } +var NilPointer *string + func test(name string) { defer func() { if x := recover(); x != nil { @@ -21,8 +23,7 @@ func test(name string) { fmt.Printf(" done\n") }() fmt.Printf("%s:", name) - var s *string - _ = *s + *NilPointer = name fmt.Print("SHOULD NOT BE HERE") } Index: libgo/go/runtime/testdata/testprogcgo/crash.go =================================================================== --- libgo/go/runtime/testdata/testprogcgo/crash.go (revision 249205) +++ libgo/go/runtime/testdata/testprogcgo/crash.go (working copy) @@ -13,6 +13,8 @@ func init() { register("Crash", Crash) } +var NilPointer *string + func test(name string) { defer func() { if x := recover(); x != nil { @@ -21,8 +23,7 @@ func test(name string) { fmt.Printf(" done\n") }() fmt.Printf("%s:", name) - var s *string - _ = *s + *NilPointer = name fmt.Print("SHOULD NOT BE HERE") }