Open
Description
I ran into an issue with cgo, when integrating Go with some C code. The attached tarball contains a minimal example that reproduces the problem. Basicaly, passing a variable of a typedef'd array type to a function accepting a const argument results in a "type mismatch" compilation error. C: typedef unsigned char Bar[12]; void foo(Bar* f); // this works void foo2(const Bar* f); // this confuses cgo Go: func main() { var v C.Bar C.foo(&bar) // this works C.foo2(&bar) // error, pasted below } This doesn't happen on Mac OS, go version go1.2 darwin/amd64, I don't know about Windows builds. What steps will reproduce the problem? 1. tar zxf const-bug.tar.gz && cd const-bug && make What is the expected output? Program should compile. What do you see instead? src/kg/constbug/main.go:12: cannot use &bar (type *_Ctype_Bar) as type *[12]_Ctype_unsignedchar in function argument Which compiler are you using (5g, 6g, 8g, gccgo)? 6g Which operating system are you using? Ubuntu 12.04 Which version are you using? (run 'go version') go version go1.2 linux/amd64 Installed from https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
Attachments:
- const-bug.tar.gz (1144 bytes)