Optional (empty) string argument

Philippe Schaffnit P.Schaffnit@access.rwth-aachen.de
Wed Aug 15 13:26:00 GMT 2007


Hi!

I see that you have flagged it as 'wrong-code': is it? (for whatever
it's worth the Lahey compiler at its pickiest doesn't complain about
it...)

Philippe

François-Xavier Coudert wrote:
> 
> 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