github.com/MangoDowner/go-gm@v0.0.0-20180818020936-8baa2bd4408c/misc/cgo/test/issue8428.go (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // This test fails on older versions of OS X because they use older buggy 6 // versions of Clang that emit ambiguous DWARF info. See issue 8611. 7 // +build !darwin 8 9 package cgotest 10 11 // Issue 8428. Cgo inconsistently translated zero size arrays. 12 13 /* 14 struct issue8428one { 15 char b; 16 char rest[]; 17 }; 18 19 struct issue8428two { 20 void *p; 21 char b; 22 char rest[0]; 23 char pad; 24 }; 25 26 struct issue8428three { 27 char w[1][2][3][0]; 28 char x[2][3][0][1]; 29 char y[3][0][1][2]; 30 char z[0][1][2][3]; 31 }; 32 */ 33 import "C" 34 35 import "unsafe" 36 37 var _ = C.struct_issue8428one{ 38 b: C.char(0), 39 // The trailing rest field is not available in cgo. 40 // See issue 11925. 41 // rest: [0]C.char{}, 42 } 43 44 var _ = C.struct_issue8428two{ 45 p: unsafe.Pointer(nil), 46 b: C.char(0), 47 rest: [0]C.char{}, 48 } 49 50 var _ = C.struct_issue8428three{ 51 w: [1][2][3][0]C.char{}, 52 x: [2][3][0][1]C.char{}, 53 y: [3][0][1][2]C.char{}, 54 z: [0][1][2][3]C.char{}, 55 }