Skip to content

cmd/cgo: size of struct with 0 length trailing field has changed #11925

Closed
@ebfe

Description

@ebfe
package main

import (
        "fmt"
        "unsafe"
)

/*
struct st {
        int a;
        char d[0];
};
*/
import "C"

func main() {
        var s C.struct_st
        fmt.Println(unsafe.Sizeof(s))
}
$ go version
go version devel +c1ccbab Wed Jul 29 21:44:27 2015 +0000 linux/amd64
$ go run t.go
8

With go 1.4

$ go version
go version go1.4.2 linux/amd64
$ go run t.go
4

Is this expected? This potentially breaks a lot of c-bindings.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions