Re: About adoption of implicit zero initialisation of POD types in
the C++ standard
On Apr 9, 10:30 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
Ioannis Vranos wrote:
Ioannis Vranos wrote:
peter koch wrote:
On the third hand why make such a fuss about it. It should
be built into the cortex of every C++ programmer, that
every variable is initialised on first use. Writing int i
should cause a slight sweat to occur, making you
initialise i right away or at least in the very next
sentence.
What about oversights? This is the way bugs can be
introduced, and this is the problem the initialisation
checks of POD types aim to solve.
Perhaps the best solution to this, is not
zero-initialisation, but compiler errors, when POD types are
not initialised.
Mandating such a check would break an awful lot of existing
code.
Only code that was already broken.
Even initializing previously pseudo-random memory can cause
devastating soft errors, e.g. the Debian/Valgrind/OpenSSL
fiasco.
http://metasploit.com/users/hdm/tools/debian-openssl/
If I understand correctly, the code in question depended on some
sort of random initialization of the data in order to
"randomize" some value. This rates as one of the most stupid
techniques I can think of. If you need a random value, there
are well established procedures for getting one. (Under Linux,
I'll seed a random number generator with values read from
/dev/random, and use it.)
Basically, peter koch is right about this. Any uninitialized
variable should give rise to perspiration.
The whole point of the "error initialization" is to increase the
chances of testing finding the use of the uninitialized value.
IMHO, even non-const variables should have a darned good
reason for not being const, and that reason usually ought to
be commented. (The obvious exception is a loop index.)
The obvious exception is anything that is going to modified:-).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34