diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /test/cmp.go | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-upstream/1.1_hg20130304.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'test/cmp.go')
-rw-r--r-- | test/cmp.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/test/cmp.go b/test/cmp.go index a56ca6ead..5be64561d 100644 --- a/test/cmp.go +++ b/test/cmp.go @@ -8,9 +8,13 @@ package main -import "unsafe" +import ( + "os" + "unsafe" +) var global bool + func use(b bool) { global = b } func stringptr(s string) uintptr { return *(*uintptr)(unsafe.Pointer(&s)) } @@ -38,8 +42,12 @@ func main() { var c string = "hello" var d string = "hel" // try to get different pointer d = d + "lo" - if stringptr(c) == stringptr(d) { - panic("compiler too smart -- got same string") + + // exp/ssa/interp can't handle unsafe.Pointer. + if os.Getenv("GOSSAINTERP") != "" { + if stringptr(c) == stringptr(d) { + panic("compiler too smart -- got same string") + } } var e = make(chan int) @@ -283,7 +291,7 @@ func main() { isfalse(ix != z) isfalse(iz != x) } - + // structs with _ fields { var x = struct { @@ -296,7 +304,7 @@ func main() { x: 1, y: 2, z: 3, } var ix interface{} = x - + istrue(x == x) istrue(x == ix) istrue(ix == x) |