- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I am getting some odd results, when i try to use the allocatable return value of a function directly as an argument of another function. Is this behavior intendet, or is this usage of the elemental-keyword false? I use the 15.0.2 compiler.
program main
implicit none
character(4) :: test_char = "Test"
character(:), allocatable :: temp_alloc
character(10) :: temp_fixed
! This should be the result
! 'Test\foo'
write(*,*) test_char // "\" // foo()
! This is the result
! 'foo f .'
write(*,*) concat(test_char, foo())
! It works as intendet, when the result of 'foo' is stored in a variable
temp_alloc = foo()
write(*,*) concat(test_char, temp_alloc)
temp_fixed = foo()
write(*,*) concat(test_char, temp_fixed)
contains
function foo()
character(:), allocatable :: foo
foo = "foo"
end function foo
! There are no problems without the 'elemental'-keyword
elemental function concat(var1,var2) result(var_result)
character(*), intent(in) :: var1, var2
character(len=max(len(var1),1)+len(var2)+1) :: var_result
! character(8) :: var_result ! This does not work, too.
var_result = var1 // "\" // var2
end function concat
end program
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To me, this appears to be a bug in Intel Fortran. I too fail to find anything in the Fortran standard that would preclude the use of elemental functions in such a context. But you may want to consider posting this on comp,lang.fortran to see what a broad spectrum of folks (some with detailed knowledge of the standard) think of this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think this is a known bug, but I will check when I get back to the office Thursday.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page