This is the mail archive of the gcc-patches@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: Patch for various warnings in gcc


On Thu, Aug 08, 2002 at 12:05:05PM +0200, Michael Matz wrote:
> >  > ra-build.c:1818: warning: `web' might be used uninitialized in this function
> 
> This warning is wrong, as web in fact is initialized in all possible
> paths.  There is no need for a fix, except maybe to silence the warning.
> Wasn't there a gcc extension ala "int a = a;" to silence it?

This topic has come up in the past; the consensus was that when GCC
couldn't prove a variable initialized, it was best to initialize it
at declaration to a value that would cause an immediate failure if
used.  (NULL, for pointers.)  The cost of doing a single
load-constant-zero instruction is unlikely to be measurable, and using
a deterministic initializer is simply good defensive programming.  We
have unconditional 'if (impossible) abort()' checks all over the
compiler - those are more expensive, surely, and no one suggests
removing them.

Personally I agree with Dale that 'int a = a;' is too obscure a way of
silencing this warning.  If we must have a way to disable it without
generating extra code, let us create __attribute__ ((initialized))
which states explicitly what is going on.

zw


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