Stefan Sperling <[email protected]> writes:

>> The scope does matter: the C standard specifies that the lifetime of an
>> object "extends from entry into the block with which it is associated
>> until execution of that block ends" [6.2.4]. An optimising compiler is
>> free to reuse stack slots once out of scope, either for other stack
>> variables or for stack space to call a function.
>
> Interesting.  I stand corrected, thanks!

gcc implements this optimisation and has -fstack-reuse to control it:

https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Code-Gen-Options.html

-- 
Philip Martin
WANdisco

Reply via email to