- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By default, Intel Fortran does not allocate the left-hand-side of an assignment, except for deferred-length strings.
(You saw that inside routine getCmdLine)
If you use the command line "-assume realloc_lhs" or "-standard-semantics" then it will do the allocation.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, this has resolved the problem!
I must admit that requiring this additional flag is a bit confusing, especially if one already specifies something like "-stand f08". If anything could be done to make this more obvious, it might save a lot of head-scratching ... :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, we've heard that request before, and we're working on it!
Glad to hear you're working again --
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Martin R. wrote:
Thank you, this has resolved the problem!
I must admit that requiring this additional flag is a bit confusing, especially if one already specifies something like "-stand f08". If anything could be done to make this more obvious, it might save a lot of head-scratching ... :)
I agree on the "confusing" part, but note -stand is only a diagnostic option - it does not direct the compiler to take any specific action unlike -assume options or -standard-semantics. I personally would prefer if -standard-semantics were the default, but Intel has its own constraints as explained in this thread:
https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/520352
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To extend Lorri's reply, consideration for making -assume realloc_lhs the default in a future release is being tracked in the internal tracking id, DPD200253547.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page