Skip to content

Commit ce5ae2f

Browse files
committed
test: use a real use function in nilptr2.go
Adjust the dummy use function to a real use. As suggested by the println calls in the test, nilptr2.go supposes to check that a used nil pointer dereference panics. This use function is not real enough so an optimized compiler such as gccgo could eliminate the call. The spec requires that even a dummy use would cause a panic. Unfortunately, due to #31151 this is not true for gccgo at -O1 or above. Change-Id: Ie07c8a5969ab94dad82d4f7cfec30597c25b7c46 Reviewed-on: https://go-review.googlesource.com/c/go/+/176579 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent f61cf6f commit ce5ae2f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/nilptr2.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ var m *M
3535
var m1 *M1
3636
var m2 *M2
3737

38-
func use(interface{}) {
38+
var V interface{}
39+
40+
func use(x interface{}) {
41+
V = x
3942
}
4043

4144
var tests = []struct{

0 commit comments

Comments
 (0)