Go-sqlite3: [WARNING] sqlite3-binding.c: In function ‘sqlite3SelectNew’

Created on 7 Jun 2020  Â·  4Comments  Â·  Source: mattn/go-sqlite3

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

Most helpful comment

#803

All 4 comments

#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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aletheia7 picture aletheia7  Â·  8Comments

jackhu1990 picture jackhu1990  Â·  11Comments

student020341 picture student020341  Â·  9Comments

jacentsao picture jacentsao  Â·  6Comments

mhat picture mhat  Â·  7Comments