Prevent stack variable initialization to zero with -g

Stuart Brooks stuartb@cat.co.za
Wed Nov 9 07:37:00 GMT 2005


Hi,

I recall reading somewhere (can't seem to find it now) that, when
compiling with -g, all stack variables are zeroed. Experience has also
shown this to be the case. However in optimized mode this can't be
relied upon - which is fine and as expected.

I was wondering if there is any way to prevent gcc from zeroing them in
"-g" mode as this tends to conceal uninitialized variables in debug
testing which then bite us in release. It would be great to be able to
force it to initialize them to some unusual byte value, but maybe that
is just wishful thinking. I have had a look through the man page but
nothing jumped out at me, maybe I missed something?

We are building on gcc 3.3.3 on Netbsd 2, and gcc 1.95.3 on Netbsd
1.6.2.

Thanks
 Stuart



More information about the Gcc-help mailing list