Since ivec is not passed to sub, I think the two calls to set_optional should be equivalent, but gfortran crashes upon the second call.
u:\vrao\fortran type xopt_bug.f90 module sub_mod contains elemental subroutine set_optional(i,idef,iopt) ! set i to (iopt,idef) if iopt (is,is not) PRESENT integer, intent(out) :: i integer, intent(in) :: idef integer, intent(in), optional :: iopt if (present(iopt)) then i = iopt else i = idef end if end subroutine set_optional ! subroutine sub(ivec) integer , intent(in), optional :: ivec(:) integer :: ivec_(2) call set_optional(ivec_,(/1,2/)) print*,"ivec_=",ivec_ call set_optional(ivec_,(/1,2/),ivec) print*,"ivec_=",ivec_ end subroutine sub end module sub_mod program main use sub_mod, only: sub call sub() end program main U:\vrao\fortran>gfortran -v Using built-in specs. Target: i386-pc-mingw32 Configured with: ../trunk/configure --prefix=/mingw --enable-languages=c,fortran --with-gmp=/home/coudert/local --disable-nls --with-ld=/mingw/bin/ld --with-as=/mingw/bin/as --disable-werror --enable-bootstrap --enable-threads --host=i386-pc-mingw32 --disable-shared --enable-libgomp Thread model: win32 gcc version 4.3.0 20061021 (experimental) U:\vrao\fortran>gfortran -W -Wall -pedantic-errors -std=f2003 -fbounds-check -Werror xopt_bug.f90 U:\vrao\fortran>a.exe Fortran runtime error: Array bound mismatch, size mismatch for dimension 1 of array 'ivec' (in file 'xopt_bug.f90', at line 20) ivec_= 1 2 -- Summary: optional argument of elemental function Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vivekrao4 at yahoo dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31148