[gfortran/patch] New: compile time shape resolution of popular intrinsics

Steven Bosscher stevenb@suse.de
Wed Jul 28 09:42:00 GMT 2004


On Wednesday 28 July 2004 11:22, Victor Leikehman wrote:
> This patch adds compile-time shape resolution of the
> following intrinsics: ALL, ANY, COUNT, CSHIFT,
> EOSHIFT, LBOUND, UBOUND, TRANSPOSE.
>
> Additionally, it fixes two related bugs: in gfc_simplify_shape and
> in gfc_get_shape.

Mostly looks OK.  One nit.

> diff -c -p -r1.5 simplify.c
> *** simplify.c  15 Jul 2004 19:55:04 -0000      1.5
> --- simplify.c  28 Jul 2004 09:13:51 -0000
> *************** gfc_simplify_shape (gfc_expr * source)
> *** 3259,3265 ****
>                                   &source->where);
>   
>     if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
> !     return result;
>   
>     ar = gfc_find_array_ref (source);
>   
> --- 3259,3265 ----
>                                   &source->where);
>   
>     if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
> !     return NULL;
>   
>     ar = gfc_find_array_ref (source);


The lines before the one you changed are these:

  result = gfc_start_constructor (BT_INTEGER, gfc_default_integer_kind (),
                                  &source->where);

  if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
-    return result;
+    return NULL;

gfc_start_constructor calls gfc_get_expr which allocates memory.  So you
are introducing a memleak with this hunk.

Gr.
Steven




More information about the Fortran mailing list