This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran/patch] New: compile time shape resolution of popular intrinsics
- From: Steven Bosscher <stevenb at suse dot de>
- To: Victor Leikehman <lei at haifasphere dot co dot il>, fortran at gcc dot gnu dot org,patches at gcc dot gnu dot org
- Date: Wed, 28 Jul 2004 11:42:13 +0200
- Subject: Re: [gfortran/patch] New: compile time shape resolution of popular intrinsics
- Organization: SUSE Labs
- References: <41077049.2090409@haifasphere.co.il>
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