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.
13 func stringptr(s string) uintptr { return *(*uintptr)(unsafe.Pointer(&s)) }
15 func isfalse(b bool) {
17 // stack will explain where
18 panic("wanted false, got true")
24 // stack will explain where
25 panic("wanted true, got false")
33 var c string = "hello"
34 var d string = "hel" // try to get different pointer
36 if stringptr(c) == stringptr(d) {
37 panic("compiler too smart -- got same string")
40 var e = make(chan int)
42 var ia interface{} = a
43 var ib interface{} = b
44 var ic interface{} = c
45 var id interface{} = d
46 var ie interface{} = e
48 // these comparisons are okay because
49 // string compare is okay and the others
50 // are comparisons where the types differ.
59 // 6g used to let this go through as true.
62 var ig interface{} = g
63 var ih interface{} = h
66 // map of interface should use == on interface values,
68 // TODO: should m[c], m[d] be valid here?
69 var m = make(map[interface{}]int)
73 println("m[ic] = ", m[ic])