1 // $G $D/$F.go && $L $F.$A && ./$A.out
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
10 // print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
11 for i := 0; i < len(a); i++ {
16 func sumpd(a []int) int {
17 // print("sumpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
19 for i := 0; i < len(a); i++ {
22 // print("sumpd t=", t, "\n");
26 func setpf(a *[20]int) {
27 // print("setpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
28 for i := 0; i < len(a); i++ {
33 func sumpf(a *[20]int) int {
34 // print("sumpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
36 for i := 0; i < len(a); i++ {
39 // print("sumpf t=", t, "\n");
43 func res(t int, lb, hb int) {
44 sb := (hb - lb) * (hb + lb - 1) / 2
55 // call ptr dynamic with ptr dynamic
57 a := make([]int, 10, 100)
58 if len(a) != 10 && cap(a) != 100 {
59 print("len and cap from new: ", len(a), " ", cap(a), "\n")
73 // call ptr fixed with ptr fixed
81 // call ptr dynamic with ptr fixed from new
85 res(sumpd(a[0:]), 0, 40)
91 // call ptr dynamic with ptr fixed from var
96 res(sumpd(a[0:]), 0, 80)
99 // generate bounds error with ptr dynamic
101 a := make([]int, 100)
104 for i := 0; i < 100; i++ {
107 print("should fault\n")
112 // generate bounds error with ptr fixed
117 for i := 0; i < 80; i++ {
120 print("should fault\n")
131 // print("testpdfault\n"); testpdfault();
132 // print("testfdfault\n"); testfdfault();