diff options
author | Ian Lance Taylor <iant@golang.org> | 2016-01-29 12:39:47 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2016-01-29 12:39:47 -0800 |
commit | b76c61051faaf0baf3215e6f811003d98639b702 (patch) | |
tree | 8dfd72e1b4a60ffafe74d38a1f28ecc498bafde2 /sqlite3-binding.h | |
parent | Merge pull request #266 from tcyrus/patch-1 (diff) | |
download | golite-b76c61051faaf0baf3215e6f811003d98639b702.tar.gz golite-b76c61051faaf0baf3215e6f811003d98639b702.tar.xz |
bind: pass &v[0] in direct call to C
In Go 1.6, the cgo checking rules are more precise when they see an
address operation as an argument to the C function. When you pass &v[0]
to a C function, the cgo check just verifies that v itself does not
contain any pointers. When you write `p := &v[0]` and then pass p to
the C function, the cgo check is conservative: it verifies that the
entire memory block to which p points does not contain any pointers.
When the bind function is called by code that passes a slice that is
part of a larger struct, this means that the cgo check will look at the
entire larger struct, not just the slice. This can cause a surprising
run time failure.
Avoid this problem by rewriting the code slightly to pass &v[0] in the
call to the C function itself.
In particular this fixes the tests of github.com/jmoiron/sqlx when using
Go 1.6.
Diffstat (limited to 'sqlite3-binding.h')
0 files changed, 0 insertions, 0 deletions