go-sqlite3
go-sqlite3 copied to clipboard
[WARNING] sqlite3-binding.c: In function ‘sqlite3SelectNew’
Hi, while I'm developing an appliation using gorm I noticed new messages shown in my terminal and said there is an issues in this package:
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 | return pNew;
| ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 | Select standin;
| ^~~~~~~
I hope this message helps you out to fix the issue. Thanks
#803
Anyone know of an alternative way to fix the warning messages that doesn't require env vars?
Using these cgo flags mentioned in #803 does work to silence the warnings but it's not ideal:
CGO_CFLAGS="-g -O2 -Wno-return-local-addr" go run main.go
@miguelmota That depends what you consider to be a fix. As mentioned in the linked issue, this warning is a false positive that could be addressed by changing how SQLite itself is implemented, but it is unclear whether such a change will be made. Alternatively, that flag could be added to this wrapper library so you don't need to manually set an environment variable.
https://github.com/mattn/go-sqlite3/blob/aa77c03e2fcb7ed283920d09a0fb6b873488b5be/sqlite3.go#L12-L24
#cgo CFLAGS: -Wno-return-local-addr
@rittneje that worked perfectly, thanks!