From 982274c96d6c9ad88a9deb07583d3b74ec2df357 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 12 Apr 2016 15:47:17 -0700 Subject: [PATCH] reflect: test that Call results are not addressable Gccgo was erroneously marking Call results as addressable, which led to an obscure bug using text/template, as text/template calls CanAddr to check whether to take the address of a value when looking up methods. When a function returned a pointer, and CanAddr was true, the result was a pointer to a pointer that had no methods. Fixed in gccgo by https://golang.org/cl/21908. Adding the test here so that it doesn't regress. Change-Id: I1d25b868e1b8e2348b21cbac6404a636376d1a4a Reviewed-on: https://go-review.googlesource.com/21930 Run-TryBot: Ian Lance Taylor Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/reflect/all_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 4a76ef8608..e1b26d9c68 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -1476,6 +1476,12 @@ func TestFunc(t *testing.T) { if i != 10 || j != 20 || k != 30 || l != (two{40, 50}) || m != 60 || n != 70 || o != 80 { t.Errorf("Call returned %d, %d, %d, %v, %d, %g, %d; want 10, 20, 30, [40, 50], 60, 70, 80", i, j, k, l, m, n, o) } + + for i, v := range ret { + if v.CanAddr() { + t.Errorf("result %d is addressable", i) + } + } } type emptyStruct struct{} -- 2.48.1