This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Warnings in simplify.c
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: FX <fxcoudert at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>
- Date: Sun, 18 May 2008 16:42:22 -0700
- Subject: Re: Warnings in simplify.c
- References: <3E5EBD7B-AA7A-4C9D-B145-5C90AE084B03@gmail.com>
On Mon, May 19, 2008 at 12:08:52AM +0100, FX wrote:
> I've started to see these:
>
> >../../trunk/gcc/fortran/simplify.c: In function ?gfc_simplify_dble?:
> >../../trunk/gcc/fortran/simplify.c:1097: warning: ?result? may be
> >used uninitialized in this function
> >../../trunk/gcc/fortran/simplify.c: In function ?gfc_simplify_real?:
> >../../trunk/gcc/fortran/simplify.c:3189: warning: ?result? may be
> >used uninitialized in this function
>
> Is it possible they were introduced by Steve's recent patch?
>
Nope.
svn diff -r 135407:135408 simplify.c | more
@@ -1123,7 +1124,10 @@ gfc_simplify_dble (gfc_expr *e)
ts.kind = gfc_default_double_kind;
result = gfc_copy_expr (e);
if (!gfc_convert_boz (result, &ts))
- return &gfc_bad_expr;
+ {
+ gfc_free_expr (result);
+ return &gfc_bad_expr;
+ }
}
return range_check (result, "DBLE");
As you can see, I added a gfc_free_expr() to complement the
'result = gfc_copy_expr()'.
If you want to silence the bogus warning,
Index: simplify.c
===================================================================
--- simplify.c (revision 135453)
+++ simplify.c (working copy)
@@ -1092,7 +1092,7 @@ gfc_simplify_dcmplx (gfc_expr *x, gfc_ex
gfc_expr *
gfc_simplify_dble (gfc_expr *e)
{
- gfc_expr *result;
+ gfc_expr *result = NULL;
if (e->expr_type != EXPR_CONSTANT)
return NULL;
@@ -3186,7 +3186,7 @@ gfc_simplify_range (gfc_expr *e)
gfc_expr *
gfc_simplify_real (gfc_expr *e, gfc_expr *k)
{
- gfc_expr *result;
+ gfc_expr *result = NULL;
int kind;
if (e->ts.type == BT_COMPLEX)
--
Steve