Russ Cox | 57eb06f | 2012-02-16 23:51:04 -0500 | [diff] [blame] | 1 | // compile |
Russ Cox | cf9f380 | 2011-06-17 16:12:14 -0400 | [diff] [blame] | 2 | |
| 3 | // Copyright 2011 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. |
| 6 | |
Rob Pike | 80a9783 | 2012-02-24 11:48:19 +1100 | [diff] [blame] | 7 | // Test unsafe.Sizeof, unsafe.Alignof, and unsafe.Offsetof all return uintptr. |
| 8 | |
Russ Cox | cf9f380 | 2011-06-17 16:12:14 -0400 | [diff] [blame] | 9 | package main |
| 10 | |
| 11 | import "unsafe" |
| 12 | |
| 13 | type T struct { |
| 14 | X int |
| 15 | } |
| 16 | |
| 17 | var t T |
| 18 | |
| 19 | func isUintptr(uintptr) {} |
| 20 | |
| 21 | func main() { |
| 22 | isUintptr(unsafe.Sizeof(t)) |
| 23 | isUintptr(unsafe.Alignof(t)) |
| 24 | isUintptr(unsafe.Offsetof(t.X)) |
| 25 | } |