Re: C/C++ Option to Initialize Variables?

2013-02-22 Thread David Brown
On 18/02/13 18:08, Robert Dewar wrote: Forgive me, but I don't see where anything is guaranteed to be zero'd before use. I'm likely wrong somewhere since you disagree. http://en.wikipedia.org/wiki/.bss This is about what happens to work, and specifically notes that it is not part of the C

Re: C/C++ Option to Initialize Variables?

2013-02-19 Thread Michael Matz
Hi, On Mon, 18 Feb 2013, Alexander Monakov wrote: On Mon, 18 Feb 2013, Michael Matz wrote: Automatic variables, as they are on the stack, are unlikely to usually get the value 0 out of pure luck, so an option to initialize them to 0xDEADBEAF doesn't make much sense. Hm, but the

C/C++ Option to Initialize Variables?

2013-02-18 Thread Jeffrey Walton
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

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Alec Teal
On 18/02/13 11:40, Jeffrey Walton wrote: 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

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Michael Veksler
On 02/18/2013 02:02 PM, Alec Teal wrote: On 18/02/13 11:40, Jeffrey Walton wrote: 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

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Jeffrey Walton
On Mon, Feb 18, 2013 at 7:42 AM, Michael Veksler mveks...@tx.technion.ac.il wrote: On 02/18/2013 02:02 PM, Alec Teal wrote: On 18/02/13 11:40, Jeffrey Walton wrote: Hi All, http://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options Is there an option to initialize

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Michael Veksler
On 02/18/2013 03:28 PM, Jeffrey Walton wrote: On Mon, Feb 18, 2013 at 7:42 AM, Michael Veksler mveks...@tx.technion.ac.il wrote: On 02/18/2013 02:02 PM, Alec Teal wrote: On 18/02/13 11:40, Jeffrey Walton wrote: Hi All,

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Jonathan Wakely
On 18 February 2013 13:28, Jeffrey Walton wrote: The reason I went looking for the flag is someone asked about a crash on the OpenSSL mailing list. I knew it was due to an uninitialized field (but they did not realize the value was not initialized). I wanted to suggest a quick way to find what

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Jeffrey Walton
On Mon, Feb 18, 2013 at 9:43 AM, Jonathan Wakely jwakely@gmail.com wrote: On 18 February 2013 13:28, Jeffrey Walton wrote: The reason I went looking for the flag is someone asked about a crash on the OpenSSL mailing list. I knew it was due to an uninitialized field (but they did not

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Andrew Haley
On 02/18/2013 03:07 PM, Jeffrey Walton wrote: On Mon, Feb 18, 2013 at 9:43 AM, Jonathan Wakely jwakely@gmail.com wrote: On 18 February 2013 13:28, Jeffrey Walton wrote: What if the .BSS section was initialized to 0xFF rather than a page full of NULLs? That could break millions of

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Jeffrey Walton
On Mon, Feb 18, 2013 at 10:34 AM, Andrew Haley a...@redhat.com wrote: On 02/18/2013 03:07 PM, Jeffrey Walton wrote: On Mon, Feb 18, 2013 at 9:43 AM, Jonathan Wakely jwakely@gmail.com wrote: On 18 February 2013 13:28, Jeffrey Walton wrote: What if the .BSS section was initialized to

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Uday Khedker
On Monday 18 February 2013 09:44 PM, Jeffrey Walton wrote: On Mon, Feb 18, 2013 at 10:34 AM, Andrew Haley a...@redhat.com wrote: On 02/18/2013 03:07 PM, Jeffrey Walton wrote: On Mon, Feb 18, 2013 at 9:43 AM, Jonathan Wakely jwakely@gmail.com wrote: On 18 February 2013 13:28, Jeffrey

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Michael Matz
Hi, On Mon, 18 Feb 2013, Jeffrey Walton wrote: On Mon, Feb 18, 2013 at 10:34 AM, Andrew Haley a...@redhat.com wrote: On 02/18/2013 03:07 PM, Jeffrey Walton wrote: On Mon, Feb 18, 2013 at 9:43 AM, Jonathan Wakely jwakely@gmail.com wrote: On 18 February 2013 13:28, Jeffrey Walton

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Alexander Monakov
On Mon, 18 Feb 2013, Michael Matz wrote: Automatic variables, as they are on the stack, are unlikely to usually get the value 0 out of pure luck, so an option to initialize them to 0xDEADBEAF doesn't make much sense. Hm, but the following comment from init-regs.c indicates that GCC will set

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Robert Dewar
Forgive me, but I don't see where anything is guaranteed to be zero'd before use. I'm likely wrong somewhere since you disagree. http://en.wikipedia.org/wiki/.bss This is about what happens to work, and specifically notes that it is not part of the C standard. There is a big difference

Re: C/C++ Option to Initialize Variables?

2013-02-18 Thread Robert Dewar
Wrong. It specifies that objects with static storage duration that aren't explicitely initialized are initialized with null pointers, or zeros depending on type. 6.7.8.10. OK, that means that the comments of my last mesage don't apply to variables of this type. So they should at least