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


 > From: Zack Weinberg <zack@codesourcery.com>
 > > 
 > > 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.

The attribute would be more readable but it would still suffer from
the non-determinism, right?

I favor my original '= 0' patch.  Michael is that ok?

		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Solutions


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