Commit 982274c9 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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 <iant@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent f0c5b8b9
......@@ -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{}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment