This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch fortran]: Fix warnings in resolve.c
On 06/08/2010 11:10 AM, Kai Tietz wrote:
> this patch fixes two warnings about "might be used uninitialized"
> warnings.
> +++ gcc/gcc/fortran/resolve.c 2010-06-08 11:06:40.458536300 +0200
> @@ -6002,7 +6002,7 @@ resolve_deallocate_expr (gfc_expr *e)
> - gfc_symbol *sym;
> + gfc_symbol *sym = NULL;
I do not understand this warning. The source is as follows:
------------- < cut > ----------------
gfc_symbol *sym;
gfc_component *c;
/* Check INTENT(IN), unless the object is a sub-component of a
pointer. */
check_intent_in = 1;
if (gfc_resolve_expr (e) == FAILURE)
return FAILURE;
if (e->expr_type != EXPR_VARIABLE)
goto bad;
sym = e->symtree->n.sym;
[...]
------------- </cut > ----------------
Thus, I do not see why the compiler warns. Any idea?
> @@ -6196,7 +6196,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_
> - gfc_symbol *sym;
> + gfc_symbol *sym = NULL;
Here, I can understand the warning:
if (e->symtree)
sym = e->symtree->n.sym;
if (e->expr_type != EXPR_VARIABLE)
[...]
else
{
if (sym->ts.type == BT_CLASS)
as the compiler cannot know that the variable is indeed non-initialized.
However, I thought that file is build with -Werror thus I am surprised
that we do not get build failures. Namely, it is build here with:
-W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long
-Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-
style-definition -Wc++-compat
and -Wall turns on -Wuninitialized. However, I do not see a warning in
the logs.
Thus, can you dig a bit more (a) why you see the warning while I don't.
(b) why -Werror does not stop the build? If (a) is solved, the next
question is why it warns for sym in resolve_deallocate_expr.
Tobias