------- Comment #11 from paul dot richard dot thomas at cea dot fr  2006-04-05 
07:17 -------
(In reply to comment #7)
> I don't think this is defined code:
>     if (present (a)) call abort ()
>     call foo_ (a)
> If a is not present, you should not be able to use a in any way.

Not quite; as I recorded in PR26891 (fixed in trunk and to be fixed in 4.1
tomorrow)

12.4.1.5 Restriction on dummy arguments not present.
..... snip .....
Except as noted in the list above, it may be supplied as an actual argument
corresponding to an optional dummy argument, which is also considered not to be
associated with an actual argument.

The code below works correctly (and in the same way as DF6.0 and ifort).

I cannot see a bug in this PR.

Paul

module mod
implicit none

private

public bar_
interface bar_
module procedure bar
end interface

public foo_
interface foo_
module procedure foo
end interface

contains

  subroutine bar (a)
    real(kind=kind(1.0d0)), dimension(:,:), optional :: a
    if (present(a)) then
      print *, "present in BAR"
    else
      print *, "not present in BAR"
    ENDIF
    call foo_ (a) ! Optional dummy and optional actual => Acceptable
  end subroutine bar

  subroutine foo(a)
    real(kind=kind(1.0d0)), dimension(:,:), optional :: a
    if (present(a)) then
      print *, "present in FOO"
    else
      print *, "not present in FOO"
    ENDIF
  end subroutine foo

end

program main
 use mod
 real(kind=kind(1.0d0)), dimension(1,1) :: a
 call bar_ ()
 call bar_ (a)
end program main


-- 


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

Reply via email to