This is the mail archive of the gcc@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]

Re: Uninitialized warnings


On Tue, Jul 17, 2001 at 09:51:06AM -0700, Dale Johannesen wrote:
> we're the first people to think of this, which gives me pause.  Is a 
> patch that checks for uninitalized variables even without optimization 
> likely to be accepted?

Please don't add any warning that can generate false positives.
I'd rather have no warning at all for 100 actual bugs than
100 correct warnings and a false positive.  The reason for
that is that I always use -Werror: I want gcc to abort when
a warning is generated.  The reason for THAT is that a warning
always means that something *is* wrong and will (likely) cause
a runtime error.

If I'd have to suggest an alternative/compromise, then I'd say:
make it possible to temporally turn off a specific warning in
the source code.

For example:

void bar(int k)
{
  int i;
  assert( k >= -1 );
  if (k == -1)
    i = 2;
  else if (k == 0)
    i = 3;
  if (k > 0)
    foo(3);
  else
#pragma warning 45 push,off		// suppress 'possible uninitialized use of i'
    foo(i);
#pragma warning 45 pop
}

-- 
Carlo Wood <carlo@alinoe.com>


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