github.com/mdempsky/go@v0.0.0-20151201204031-5dd372bd1e70/misc/cgo/test/issue5242.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  // Issue 5242.  Cgo incorrectly computed the alignment of structs
     6  // with no Go accessible fields as 0, and then panicked on
     7  // modulo-by-zero computations.
     8  
     9  package cgotest
    10  
    11  /*
    12  typedef struct {
    13  } foo;
    14  
    15  typedef struct {
    16  	int x : 1;
    17  } bar;
    18  
    19  int issue5242(foo f, bar b) {
    20  	return 5242;
    21  }
    22  */
    23  import "C"
    24  
    25  import "testing"
    26  
    27  func test5242(t *testing.T) {
    28  	if got := C.issue5242(C.foo{}, C.bar{}); got != 5242 {
    29  		t.Errorf("got %v", got)
    30  	}
    31  }