-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
tested with 1.7.5 and 1.8.1
What operating system and processor architecture are you using (go env
)?
linux/amd64
What did you do?
package main
/*
struct foo {
int x;
char padding;
char y[];
};
*/
import "C"
import "fmt"
var Y C.struct_foo
func main() {
fmt.Println(Y.y)
}
What did you expect to see?
Y.y undefined (type C.struct_foo has no field or method y)
(because Y.y is a zero-length field and Go code cannot refer to these fields)
What did you see instead?
Compiles and prints:
[]
I've checked that it's dependent on memory alignment. If the padding
field is removed from struct foo, generated cgo type doesn't have the y
field. With the padding, the field is included.
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.