When compiling the attached testcase using ifort "bugrep.f90" and calling the generated executable via "./a.out blah blah blah", the output is:
nargs: 3
tmp=blah
stored=blah
tmp=blah
stored=blah
tmp=blah
stored=blah
size(args)= 0
However, I'd expect an output of:
nargs: 3
tmp=blah
stored=blah
tmp=blah
stored=blah
tmp=blah
stored=blah
size(args)= 3
blah
blah
blah
This is what recent versions of GNU Fortran give me. This looks like a bug in the Intel compiler.
Test case:
module mod
implicit none
type,public :: string
character (len=:), allocatable :: s
end type
contains
function getCmdLine()
type(string),dimension(:),allocatable :: getCmdLine
character(len=1024) :: tmp
integer m
print *,"nargs:", command_argument_count()
allocate(getCmdLine(command_argument_count()))
do m=1,command_argument_count()
call get_command_argument(m, tmp)
print *,"tmp=",trim(tmp)
getCmdLine(m)%s=trim(adjustl(tmp))
print *,"stored=",getCmdLine(m)%s
end do
end function
end module
program test
use mod
implicit none
type(string),allocatable::args(:)
integer i
args=getCmdLine()
print *,"size(args)=",size(args)
do i=1,size(args)
print *,args(i)%s
enddo
end program