SQLite Forum

warning: function may return address of local variable [-Wreturn-local-addr]
> perhaps this should be made into a global to avoid the warning.

The "`standin`" local variable is a structure used to clean up and free
prior memory allocations associated with the parse tree after a malloc()
failure while trying to acquire space to build a "`Select`" object.

  *  We cannot use a global for this, as that would cause problems if
     two or more threads all suffer a malloc() failure at about the
     same time.

  *  We cannot malloc for space.  The whole reason for using "`standin`"
     in the first place is that malloc isn't working.

Hence "`standin`" must be a stack variable.

As you observe, the logic of the overall system and especially the
assert() on the previous line demonstrate that the value returned
cannot be the stack variable.

This problem only arises because SQLite is very careful to not leak
memory nor crash following a malloc() failure.  We test that 
using simulated malloc() failures.

Perhaps you should bring this false-positive warning message to the
attention of the people who maintain the CGo compiler?