Optional (empty) string argument

François-Xavier Coudert fxcoudert@gmail.com
Wed Aug 15 13:21:00 GMT 2007


I think that's a bug, and it also appears with only one level of
indirection, by using a non-parameter string:

  CHARACTER(LEN=1) :: s
  s = " "
  CALL bar (s)
  CALL bar (trim(s))
CONTAINS
  SUBROUTINE bar (s)
    CHARACTER(LEN=*), OPTIONAL :: s
    IF (PRESENT (s)) THEN
      WRITE(*,"(A)") "Argument: |" // s // "|"
    ELSE
      WRITE(*,"(A)") "No argument"
    END IF
  END SUBROUTINE bar
END

$ gfortran o.f90 && ./a.out
Argument: | |
No argument

Can you file a PR about this, and CC me?

Thanks,
FX



More information about the Fortran mailing list