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

Cgo function produces "warning: assignment from incompatible pointer type" #5579

Closed
gopherbot opened this issue May 28, 2013 · 1 comment
Closed

Comments

@gopherbot
Copy link

by kballard:

Building launchpad.net/goyaml produces a series of warnings:

decode.go: In function ‘_cgo_27a928056cbd_Cfunc_event_alias’:
decode.go:34:7: warning: assignment from incompatible pointer type [enabled by default]
decode.go: In function ‘_cgo_27a928056cbd_Cfunc_event_mapping_start’:
decode.go:44:7: warning: assignment from incompatible pointer type [enabled by default]
decode.go: In function ‘_cgo_27a928056cbd_Cfunc_event_scalar’:
decode.go:54:7: warning: assignment from incompatible pointer type [enabled by default]
decode.go: In function ‘_cgo_27a928056cbd_Cfunc_event_sequence_start’:
decode.go:64:7: warning: assignment from incompatible pointer type [enabled by default]

The Cgo-generated function for the first warning looks like

void
_cgo_27a928056cbd_Cfunc_event_mapping_start(void *v)
{
    struct {
        yaml_event_t* p0;
        const struct {yaml_char_t* anchor; yaml_char_t* tag; int implicit; yaml_mapping_style_t style; }* r;
    } __attribute__((__packed__)) *a = v;
    a->r = (const struct {yaml_char_t* anchor; yaml_char_t* tag; int implicit; yaml_mapping_style_t style; }*) event_mapping_start((void*)a->p0);
}

The warning is on the `a->r = ...` line.

If I ask Clang to build this file, the warning is a bit more verbose:

decode.go:34:7: warning: incompatible pointer types assigning to 'const struct
<anonymous struct at decode.go:32:9> *' from 'const struct <anonymous struct at
      decode.go:34:16> *' [-Wincompatible-pointer-types]
        a->r = (const struct {yaml_char_t* anchor; }*) event_alias((void*)a->p0);
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


What steps will reproduce the problem?
1. Build launchpad.net/goyaml

What is the expected output?
No warnings

What do you see instead?
The warnings listed above

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
Ubuntu 12.04

Which version are you using?  (run 'go version')
go version go1.1 linux/386
@ianlancetaylor
Copy link
Contributor

Comment 1:

Status changed to Duplicate.

Merged into issue #4857.

@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
Development

No branches or pull requests

2 participants