> Shouldn't we turn on warnings by the compiler on uninitialized
> variables? This can also be helpful.

Those warnings should already be enabled, at least with GCC.

Yes, the compiler can detect unitialized variables, 

But, that introduces a new problem.  There are a lot of tools out there (like GCC) that can find unitialized variables (or more specifically, variables which are used before initialization).  I've seen too many less-scarred developers add an " = NULL" to quiet down the tool.  But that's (arguably) worse than leaving the variable uninitialized - if you simply initialize a variable to a known (but not correct) value, you've disabled the tool; it can't help you find improperly initialized variables anymore.  The variable has a value, but you still don't know at which point in time it has a correct value.

That's another reason I prefer initializers (and nested variable declarations) - I can put off creating the variable until I can assign a meaningful value to it.   (I don't go so far as to introduce artificial scopes just for the sake of nesting variable declarations).

Too many scars...

            -- Korry

Reply via email to