The maintenance problems that uninitialised locals cause (particularly pointers) will be obvious to anyone who has done a bit of c/c++ maintenance or enhancement, but I still see them and occasionally hear performance implications given as their justification.
It's easy to demonstrate in c that redundant initialisation is optimised out:
$ less test.c
#include <stdio.h>
main()
{
#ifdef INIT_LOC
int a = 33;
int b;
memset(&b,66,sizeof(b));
#else
int a;
int b;
#endif
a = 0;
b = 0;
printf ("a = %i, b = %i\n", a, b);
}
$ gcc --version
gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
[Not Optimised:]
$ gcc test.c -S -o no_init.s; gcc test.c -S -D INIT_LOC=1 -o init.s; diff no_in
it.s init.s
22a23,28
> movl $33, -4(%ebp)
> movl $4, 8(%esp)
> movl $66, 4(%esp)
> leal -8(%ebp), %eax
> movl %eax, (%esp)
> call _memset
33a40
> .def _memset; .scl 3; .type 32; .endef
[Optimised:]
$ gcc test.c -O -S -o no_init.s; gcc test.c -O -S -D INIT_LOC=1 -o init.s; diff
no_init.s init.s
$
So WRT performance under what circumstances is mandatory variable initialisation NOT a good idea?
IF applicable, no need to restrict answers to c/c++ but please be clear about the language/environment (and reproducible evidence much preferred over speculation!)