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: struct size calculation error OS X 10.9 Mavericks #6368

Closed
gopherbot opened this issue Sep 11, 2013 · 7 comments

Comments

@gopherbot
Copy link

commented Sep 11, 2013

by mazdak@chango.com:

On OS X 10.9 Mavericks, when building the following code snippet, I get the following
error:

# command-line-arguments
xxxx.go:190:12: struct size calculation error off=40 bytesize=32

The same go file (which is actually a cgo file) works on older versions of OS X and
Linux.

To assist, here is a snippet that reproduces the above problem:

----------

package main

/*

#include <stdlib.h>

enum ct { A = 0x00, B = 0x01};
typedef enum ct ct;

typedef struct cobject_s {
  enum ct    type;
  size_t      sz;
  union {
    char    *str; // note for str: sz is strlen (not strlen+1
    void    *blob;
    int64_t   i64;   // easiest to have one large int type
  } u;

  void *free; // if this is set, this must be freed on destructuion

} cobject;


typedef struct cbin_s {
  char    bin_name[32];
  cobject object;
} cbin;

*/
import "C"

func main() {
    var a C.cbin
}
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2013

Comment 1:

Labels changed: added priority-soon, go1.2maybe, os-macosx, removed priority-triage.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Sep 13, 2013

Comment 2:

Status changed to Accepted.

@gopherbot

This comment has been minimized.

Copy link
Author

commented Oct 4, 2013

Comment 3 by mazdak@chango.com:

Just a note that OS X Mavericks (10.9) GM was released today.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2013

Comment 4:

What version of Xcode are you running? (xcodebuild -version)
@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2013

Comment 5:

I reproduced this on my non-Mavericks machine. 
g% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.8.5
BuildVersion:   12F37
g% xcodebuild -version
Xcode 4.5.2
Build version 4G2008a
g% 
It is the same problem (an inner anonymous struct/union) as issue #6472. That fix makes
this work too.

Status changed to Duplicate.

Merged into issue #6472.

@gopherbot

This comment has been minimized.

Copy link
Author

commented Oct 9, 2013

Comment 6 by mazdak@chango.com:

Is there a fix for issue #6472? I wasn't able to see a fix there. Setting CC=gcc will not
work on Mavericks as gcc no longer ships with OS X 10.9
@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2013

Comment 7:

the fix had not yet been submitted. now it is there.
changeset:   18294:71051fea795a
user:        Russ Cox <rsc@golang.org>
date:        Wed Oct 09 11:08:22 2013 -0400
summary:     debug/dwarf: handle surprising clang encoding

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015

@rsc rsc removed the go1.2maybe label Apr 14, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 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
4 participants
You can’t perform that action at this time.