| // $G $D/$F.go && $L $F.$A && ./$A.out |
| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func stringptr(s string) uintptr { |
| return *(*uintptr)(unsafe.Pointer(&s)); |
| if b { panicln("wanted false, got true") } // stack will explain where |
| if !b { panicln("wanted true, got false") } // stack will explain where |
| var d string = "hel"; // try to get different pointer |
| if stringptr(c) == stringptr(d) { |
| panic("compiler too smart -- got same string") |
| // these comparisons are okay because |
| // string compare is okay and the others |
| // are comparisons where the types differ. |
| // 6g used to let this go through as true. |
| // map of interface should use == on interface values, |
| // TODO: should m[c], m[d] be valid here? |
| var m = make(map[interface{}] int); |
| panic("m[ic] = ", m[ic]); |