http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60302

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu.org

--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to janus from comment #4)
> (In reply to janus from comment #3)
> > The function 'gfc_check_c_f_pointer' was added in r197053
> 
> ... and I think that's indeed the culprit. This patch fixes it:
> 
> 
> Index: gcc/fortran/check.c
> ===================================================================
> --- gcc/fortran/check.c       (revision 207988)
> +++ gcc/fortran/check.c       (working copy)
> @@ -3944,16 +3944,17 @@ gfc_check_c_f_pointer (gfc_expr *cptr, gfc_expr *f
>    if (shape)
>      {
>        mpz_t size;
> -
> -      if (gfc_array_size (shape, &size)
> -       && mpz_cmp_ui (size, fptr->rank) != 0)
> +      if (gfc_array_size (shape, &size))
>       {
> +       if (mpz_cmp_ui (size, fptr->rank) != 0)
> +         {
> +           mpz_clear (size);
> +           gfc_error ("SHAPE argument at %L to C_F_POINTER must have the 
> same "
> +                     "size as the RANK of FPTR", &shape->where);
> +           return false;
> +         }
>         mpz_clear (size);
> -       gfc_error ("SHAPE argument at %L to C_F_POINTER must have the same "
> -                  "size as the RANK of FPTR", &shape->where);
> -       return false;
>       }
> -      mpz_clear (size);
>      }
>  
>    if (fptr->ts.type == BT_CLASS)
> 
> 
> 
> We should not free 'size' unless gfc_array_size is successful!

Hi Janus,

Perhaps you had better commit this asap.

Cheers

Paul

Reply via email to