User account creation filtered due to spam.

Bug 34759 - Assumed size array reference not allowed in SHAPE intrinsic, even though last subscript specified
Summary: Assumed size array reference not allowed in SHAPE intrinsic, even though last...
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Tobias Burnus
Keywords: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
Reported: 2008-01-12 20:15 UTC by Dick Hendrickson
Modified: 2008-01-13 21:49 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2008-01-12 22:28:20


Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2008-01-12 20:15:59 UTC
With gfortran 4.3.0 20080109 I get an incorrect error message
"Error: 'source' argument of 'shape' intrinsic at (1) must not
be an assumed size array" with the following little test case

       subroutine j_assumed_size(A,N)
       dimension A(10,11,12,*)
       k = shape(A(:,:,:,N))
       l = shape(A(:,:,:,3))

I believe assumed size arrays are allowed provided the last subscript
is specified.

Dick Hendrickson
Comment 1 Tobias Burnus 2008-01-12 21:13:54 UTC
Confirm, though your reduced test case is invalid (the variables k and l need to be arrays. Corrected test case:

       subroutine j_assumed_size(A,N)
       dimension A(10,11,12,*), k(3), l(3)
       k = shape(A(:,:,:,N))
       l = shape(A(:,:,:,3))

"SOURCE may be of any type. It may be a scalar or an array. It shall not be an
unallocated allocatable or a pointer that is not associated. It shall not be an
assumed-size array."

The shall-nots do not apply for the rank-3 arrays A(:,:,:,N) and A(:,:,:,3). Actually, this could be a wider problem, which is not only limited to check.c's gfc_check_shape. (For actual/dummy argument checking, I added a note to PR 34665.)

Thanks for the report.
Comment 2 Tobias Burnus 2008-01-12 22:28:20 UTC
Patch. I think this is the only place to change, interface's compare_actual_formal is actually ok.

Index: gcc/fortran/check.c
--- gcc/fortran/check.c (revision 131492)
+++ gcc/fortran/check.c (working copy)
@@ -2394,7 +2394,7 @@ gfc_check_shape (gfc_expr *source)

   ar = gfc_find_array_ref (source);

-  if (ar->as && ar->as->type == AS_ASSUMED_SIZE)
+  if (ar->as && ar->as->type == AS_ASSUMED_SIZE && ar->type == AR_FULL)
       gfc_error ("'source' argument of 'shape' intrinsic at %L must not be "
                 "an assumed size array", &source->where);
Comment 3 Tobias Burnus 2008-01-13 17:41:52 UTC
Comment 4 Tobias Burnus 2008-01-13 21:29:14 UTC
Subject: Bug 34759

Author: burnus
Date: Sun Jan 13 21:28:30 2008
New Revision: 131511

2008-01-13  Tobias Burnus  <>

        PR fortran/34759
        * check.c (gfc_check_shape): Accept array ranges of
        assumed-size arrays.

2008-01-13  Tobias Burnus  <>

        PR fortran/34759
        * gfortran.dg/assumed_size_refs_4.f90: New.


Comment 5 Tobias Burnus 2008-01-13 21:49:05 UTC
Fixed on the trunk (4.3.0).

Thanks for the report!