Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: error involving C zero-length array #2806

Closed
gopherbot opened this issue Jan 28, 2012 · 3 comments

Comments

@gopherbot
Copy link

commented Jan 28, 2012

by giacomo.tartari:

What steps will reproduce the problem?

1.
//put this code in $GOPATH/src/mytest/mytest.go
package mytest

/*
typedef struct{
        int x;
        int data[0];
} cStruct;

*/
import "C"

type GoStruct struct {
        C.cStruct
}

2.
cd $GOPATH/src/mytest
go build

What is the expected output?


What do you see instead?
# mytest
struct size calculation error

Which compiler are you using (5g, 6g, 8g, gccgo)?
$6g -V
6g version weekly.2012-01-27 11520

Which operating system are you using?
OS X Lion 10.7.2 

Which revision are you using?  (hg identify)
$ hg identify
23995c78329e tip

Please provide any additional information below.

It compiles on Snow leopard or using the "old" gcc installed via macports.

Here is with the default gcc:

$ gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/src/configure
--disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2
--mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm-
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin11
--enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/dst-llvmCore/Developer/usr/local
--program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11
--target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
$ go build
# mytest
struct size calculation error

And here with the "old" gcc

$export $GCC=/opt/local/bin/gcc-apple-4.2
$ $GCC
i686-apple-darwin11-gcc-apple-4.2.1: no input files
$ $GCC -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_apple-gcc42/apple-gcc42/work/objroot/src/configure
--disable-checking --prefix=/opt/local --mandir=/opt/local/share/man
--enable-languages=c,c++,objc,obj-c++ --libexecdir=/opt/local/libexec/apple-gcc42
--libdir=/opt/local/lib/apple-gcc42 --includedir=/opt/local/include/apple-gcc42
--program-suffix=-apple-4.2 --with-system-zlib --disable-nls --with-gmp=/opt/local
--with-mpfr=/opt/local --with-slibdir=/usr/lib --build=x86_64-apple-darwin11
--enable-werror-always --program-prefix=i686-apple-darwin11-
--host=x86_64-apple-darwin11 --target=i686-apple-darwin11
--with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
$ go build
$
@rsc

This comment has been minimized.

Copy link
Contributor

commented Jan 29, 2012

Comment 1:

Labels changed: added priority-go1, removed priority-triage.

Owner changed to builder@golang.org.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2012

Comment 2:

Status changed to Started.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Feb 19, 2012

Comment 3:

This issue was closed by revision 1a0c8fe.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015

@rsc rsc removed the priority-go1 label Apr 10, 2015

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.