Last active
November 15, 2018 07:48
-
-
Save akalin-keybase/6d075a61e683a4b2e2424638308e95c5 to your computer and use it in GitHub Desktop.
Repro for go 1.10 bug with CoreFoundation types and cgo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build darwin | |
// +build go1.10 | |
package bugrepro | |
/* | |
#cgo LDFLAGS: -framework CoreFoundation | |
#include <CoreFoundation/CoreFoundation.h> | |
*/ | |
import "C" | |
// If this function is moved to file2, compilation succeeds. | |
func returnsCFArrayRef() C.CFArrayRef { | |
return C.CFArrayRef(0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build darwin | |
// +build !go1.10 | |
package bugrepro | |
/* | |
#cgo LDFLAGS: -framework CoreFoundation | |
#include <CoreFoundation/CoreFoundation.h> | |
*/ | |
import "C" | |
// If this function is moved to file2, compilation succeeds. | |
func returnsCFArrayRef() C.CFArrayRef { | |
return C.CFArrayRef(nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build darwin | |
package bugrepro | |
/* | |
#cgo LDFLAGS: -framework CoreFoundation -framework IOKit | |
#include <CoreFoundation/CoreFoundation.h> | |
*/ | |
import "C" | |
// If this function is uncommented, compilation succeeds. | |
/* | |
func fn1() { | |
var _ C.CFArrayRef | |
} | |
*/ | |
func bugRepro() { | |
arr := returnsCFArrayRef() | |
// If arr is replaced with C.CFArrayRef(arr), compilation succeeds. | |
C.CFArrayCreateCopy(nil, arr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment