Re: Warn if making external references to local stack memory?

2012-04-10 Thread Fredrik Hederstierna
>> GCC does warn if returning a pointer to a local variable (stack memory). >> But there are alot of more cases where GCC could possibly warn, >> eg. when references are made to local variables or stack memory. >> >> See this attached example code. >> GCC warn

Re: Warn if making external references to local stack memory?

2012-04-09 Thread Ian Lance Taylor
"sa...@hederstierna.com" writes: > GCC does warn if returning a pointer to a local variable (stack memory). > But there are alot of more cases where GCC could possibly warn, > eg. when references are made to local variables or stack memory. > > See this attached exam

Warn if making external references to local stack memory?

2012-04-08 Thread sa...@hederstierna.com
Hi GCC does warn if returning a pointer to a local variable (stack memory). But there are alot of more cases where GCC could possibly warn, eg. when references are made to local variables or stack memory. See this attached example code. GCC warns for first case, but not the others. I think all

Re: stack memory

2005-10-21 Thread Mike Stump
On Oct 21, 2005, at 8:05 AM, Ivan Novick wrote: With the sun compiler, the declared buffer is pushed onto the stack upon entry into function foo and not only when it goes into scope. Yup. Do you know if gcc will use the stack for the buffer if it never goes into scope? Yes, it usually wi

stack memory

2005-10-21 Thread Ivan Novick
Hi, With the sun compiler, the declared buffer is pushed onto the stack upon entry into function foo and not only when it goes into scope. Do you know if gcc will use the stack for the buffer if it never goes into scope? function foo() { if ( debug > 0 ) { char debug_buffer[4096