www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DMD flag -gs and -gx

reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
What role does the DMD flags -gs and -gx play?

The documentation says

   -gs            always emit stack frame
   -gx            add stack stomp code

which I don't know what it means.
May 13 2016
parent Rene Zwanenburg <renezwanenburg gmail.com> writes:
On Friday, 13 May 2016 at 10:19:04 UTC, Nordlöw wrote:
   -gs            always emit stack frame
IIRC, not emitting a stack frame is an optimization which confuses debuggers. So I think this can be used to make optimized builds a bit easier to debug.
   -gx            add stack stomp code
After a function returns the stack normally still contains the local variables of that function, but they can be overwritten at any time (which is why it's unsafe to escape references to stack variables from a function). Using this switch will cause the compiler to overwrite the stack with bogus values before returning, which will help with early detection of bugs like the above. It can also be useful in security contexts where a function operates on sensitive data.
May 13 2016