Cloned from PR 36771. See also
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/3d909edac01e60e2#

Since F2003 one can pass a "string" to a character(len=1),dimension(*)
dummy. The question is whether this should also work for generic
resolution or not.

The "call One('String')" (one = generic name) of the following program
is rejected by gfortran, ifort, NAG f95 and g95, stating that no
matching specific procedure could be found. On the other hand, all of
them accept "call Two" (= specific name). My question is now whether
"call One" should work as well (which would indicate a bug in all four
compilers) or not.

My gut feeling is that it is valid, but I cannot really pin point it in
the standard.*

*** Action item: If valid, gfortran should accept this.


Another question: Am I reading it correctly that if the default kind has
not the same value as "UCS4 = selected_char_kind('ISO_10646')" then a
call with an actual argument ucs4_"string" to a procedure with
array-valued ucs4-kind dummy argument is invalid Fortran 2003 and should
be rejected by the compiler with -std=f2003? This also holds for Fortran
2008 (current draft), does it?**

*** Action item: If invalid, we need to rejected (kind /= 1) character used
with storage association when -std < gnu is given. (I'm almost positive that it
is invalid.)

(One needs to be careful this also works with rank > 1.)

MODULE modtest
  USE ISO_C_BINDING
  INTERFACE One
     MODULE PROCEDURE Two
  END INTERFACE
CONTAINS
  SUBROUTINE Two( chr ) bind(C)
    CHARACTER(LEN=1, KIND=C_CHAR), DIMENSION(*) :: chr
  END SUBROUTINE Two
END MODULE modtest

PROGRAM main
  USE ISO_C_BINDING
  USE modtest
  CHARACTER(LEN=4, KIND=C_CHAR) :: chrScalar
  chrScalar = 'Scal'
  CALL One( chrScalar )
  CALL Two( chrScalar )
END PROGRAM main


* Regarding the standard, I think "12.4.1.5 Sequence association" is the
most important section, but I also looked at "12.4.1.2 Actual arguments
associated with dummy data objects", "16.4.3 Storage association" and
(for c_char) "15.2 Interoperability between Fortran and C entities".

** "12.5.2.11 Sequence association" also talks about default kind and
c_char only.


-- 
           Summary: Character storage association - actual <-> dummy
                    argument
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, diagnostic
          Severity: normal
          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=38506

Reply via email to