This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Warnings in simplify.c


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


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