This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: comiler warnings


> Is it a compiler's bug that it doesn't warn about it in debug mode ?

Most programmers want debug compilations to complete as fast as possible.
This is so as to optimize the edit/compile/debug cycle.  During debugging
they also usually do not want to deal with the obfuscation introduced by
optimization.

The analysis machinery needed to identify an uninitialized variable is
moderately expensive to set up and run.  But since that machinery is a
prerequisite for many optimization these diagnoses can be generated at
almost no cost when performing such optimized compilations.

Keep in mind as well that such analyses are not foolproof.  One of my
favorites is a loop which uses an uninitialized 32 bit integer variable
as a shift register, accumulating one well defined bit every iteration.
After 32 times around the loop the variable's contents are entirely
defined.  Yet compilers regularly warn we that the state of my variable
coming into the shift may be undefined.

If you really want these kinds of diagnoses you need only to perform an
optimized compilation every now and then.

/john


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]