This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/30940] New: Fortran 2003: Scalar CHARACTER supplied to array dummy


The following valid program is rejected by gfortran with the error:
  Type/rank mismatch in argument 'in'

-------------------------
program main
implicit none
character(len=10) :: digit_string = '123456789'
character :: digit_arr(10)
call copy(digit_string, digit_arr)
print '(1x, a1)',digit_arr(1:9)
contains
  subroutine copy(in, out)
    character, dimension(10) :: in, out
    out(1:10) = in(1:10)
  end subroutine copy
end program main
-------------------------

The program compiles with g95 -std=f2003 and NAG f95 -f2003. They give for
-std=f95 and no -f2003 the warning/error:
  Error: Cannot pass scalar to array argument 'in'
  Extension: bar.f90, line 5: Scalar CHARACTER supplied for dummy IN of COPY

I think this is somewhere embedded in section "12.4.1.5 Sequence association"
of the Fortran 2003 standard.

"If the actual argument is of type default character or of type character with
the C character kind, and is an array expression, array element, or array
element substring designator, the element sequence consists of the storage
units beginning with the first storage unit of the actual argument and
continuing to the end of the array. The storage units of an array element
substring designator are viewed as array elements consisting of consecutive
groups of storage units having the character length of the dummy array.

If the actual argument is of type default character or of type character with
the C character kind, and is a scalar that is not an array element or array
element substring designator, the element sequence consists of the storage
units of the actual argument.

An actual argument that represents an element sequence and corresponds to a
dummy argument that is an array is sequence associated with the dummy argument
if the dummy argument is an explicit-shape or assumed-size array. The rank and
shape of the actual argument need not agree with the rank and shape of the
dummy argument, but the number of elements in the dummy argument shall not
exceed the number of elements in the element sequence of the actual argument.
If the dummy argument is assumed-size, the number of elements in the dummy
argument is exactly the number of elements in the element sequence."


-- 
           Summary: Fortran 2003: Scalar CHARACTER supplied to array dummy
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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