J M Sharath Bharadwaj bharadwaj wrote:
Is GCC going to perform a better optimization, if I am going to
initialize the variable explicitly. I am asking this because I was
reading the GCC online doc for warning options like as in
http://www.cs.cmu.edu/cgi-bin/info2www?(gcc.info)Warning%20Options
Maybe you need to give some example code to explain the question you are
trying to ask.
The optional warning for uninitialized automatic variables may catch
programming errors that involve actual use of uninitialized values, but
more often it generates false warnings where the compiler fails to
understand the flow of control and doesn't realize no possible path
through the code uses the uninitialized value.
Many programmers add an unnecessary initial value to variables, so they
can eliminate the false warning while leaving that type of warning
enabled (for its benefits when the code really is wrong).
In most cases adding an unnecessary initialization will make the code
slightly less optimized. I'm sure one could construct some strange
example in which adding an unnecessary initialization would make the
code more optimal, but it would need to be pretty strange.