mirror of
https://github.com/golang/go
synced 2024-11-05 18:56:10 -07:00
f423d616b1
CL 258938 changed the way C to Go calls work such that they now construct a C struct on the C side for the arguments and space for the results. Any pointers in the result space must be zeroed, so we just zero the whole struct. However, C makes it surprisingly hard to robustly zero any struct type. We had used a "{0}" initializer, which works in the vast majority of cases, but fails if the type is empty or effectively empty. This CL fixes this by changing how the cgo tool zero-initializes the argument struct to be more robust. Fixes #42495. Change-Id: Id1749b9d751e59eb7a02a9d44fec0698a2bf63cd Reviewed-on: https://go-review.googlesource.com/c/go/+/269337 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
16 lines
366 B
Go
16 lines
366 B
Go
// Copyright 2020 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.
|
|
|
|
package cgotest
|
|
|
|
// typedef struct { } T42495A;
|
|
// typedef struct { int x[0]; } T42495B;
|
|
import "C"
|
|
|
|
//export Issue42495A
|
|
func Issue42495A(C.T42495A) {}
|
|
|
|
//export Issue42495B
|
|
func Issue42495B(C.T42495B) {}
|