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: Michael Matz <matz@suse.de>
 > 
 > Hi,
 > 
 > On Thu, 8 Aug 2002, Kaveh R. Ghazi wrote:
 > 
 > > The patch below fixes these warnings:
 > >  > 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.

The problem is that `web' is initialized like this:

 > if (! wp->uplink)
 >   web = ...
 > if (def2web[i] != NULL)
 >   web = ...
 > if (wp->uplink)
 >   web = ...
 > 
 > <use web here>

GCC isn't smart enough to realize that an "if (! wp->uplink)" followed
later by "if (wp->uplink)" means web is always initialized.  If you
can instead write it like this:

 > if (! wp->uplink)
 >   web = ...
 > else
 >   web = ...
 > 
 > if (def2web[i] != NULL)
 >   web = ...

it would work but I don't know if reordering the third clause above
the second one is okay.  Perhaps you can take a look?



 > Wasn't there a gcc extension ala "int a = a;" to silence it?

I've never heard about that extension.  What does it do and mean?

		--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]