This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
C/C++ Option to Initialize Variables?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 18 Feb 2013 06:40:26 -0500
- Subject: C/C++ Option to Initialize Variables?
- Reply-to: noloader at gmail dot com
Hi All,
http://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options
Is there an option to initialize variables to known values in a C/C++ program?
My use case is 'debug' builds and finding use of uninitialized values
that get lucky by being 0 most of the time. For example:
void DoSomeithWithFoo(FOO** ppf) {
if(ppf && *ppf == NULL) {
*ppf = new FOO;
...
}
}
FOO* p;
DoSomeithWithFoo(&p);
So I would like something that initializes to known, but non-NULL,
such as 0xCDCDCDCD or 0xFDFDFDFD (similar to Visual Studio behavior).
Jeff