Skip to content

cmd/cgo: pointers of Objective-C classes compatibility #7039

@hajimehoshi

Description

@hajimehoshi
What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

A pointer of an Objective-C class can't be assigned to a variable as a pointer of
another Objective-C class. For example:

package main

// #cgo CFLAGS: -x objective-c                                                          
                                                                                        
                                                                                        
     
//                                                                                      
                                                                                        
                                                                                        
     
// @class Foo;                                                                          
                                                                                        
                                                                                        
     
// @class Bar;                                                                          
                                                                                        
                                                                                        
     
import "C"

func main() {
        var foo *C.Foo
        var bar *C.Bar

        foo = bar // ?                                                                                                                                                                                                                                                          

        print(foo)
        print(bar)
}

What is the expected output?
Compile Error

What do you see instead?
Compile succeeded
("0x00x0" was printed)

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

Which operating system are you using?
Mac OS X 10.9

Which version are you using?  (run 'go version')
go version go1.2 darwin/amd64

Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions