× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Brad Stone wrote:
Don't you mean returning a pointer to a STATIC variable
local to the procedure, or a global variable in the
module? Returning a pointer to a local (automatic)
variable in a procedure may work for some cases. (Likely
the cases used for your unit tests.) But fail it will,
and the symptoms will be hard to debug.

Cheers! Hans



Is this because the storage is normally reclaimed after the
calling program ends?  Or does it reclaim it when it
"needs" the extra storage?  Or after the call to the
subprocedure that non-static storage is now available for
any other app to use?


It's because you're dealing with stack storage. At any time after the procedure returns, that area of storage is subject to reuse, typically by calls to other procedures, but also (depending on CPU and O/S) by random machine interrupts. Simply, you just can't trust anything on the popped side of the stack pointer on any hardware. (For me, it's a lesson I learned the hard way while writing a LISP interpreter in PDP-11 assembler language way back in 1978.)


Cheers! Hans


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.