This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch for various warnings in gcc
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: matz at suse dot de
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 8 Aug 2002 10:49:26 -0400 (EDT)
- Subject: Re: Patch for various warnings in gcc
- References: <Pine.LNX.4.33.0208081201260.6693-100000@wotan.suse.de>
> 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