- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following example reproduces a regression in the oneAPI 2025.2 Fortran compiler that I encountered in our production code.
module m1
character(:), pointer, private :: string => null()
contains
function get()
class(*), pointer :: get
if (.not.associated(string)) allocate(string, source='foo')
get => string
end function
subroutine set(arg)
class(*), intent(in) :: arg
select type (arg)
type is (character(*))
print *, 'set received string "', arg, '"'
if (arg /= 'foo') stop 'ERROR!'
end select
end subroutine
end module
use m1
select type (s => get())
type is (character(*))
print *, 'passing string "', s, '" to set'
call set(s)
end select
end
It produces the incorrect result
$ ifx intel-20250709.f90
$ ./a.out
passing string "foo" to set
set received string ""
ERROR!
The expected output (from 2025.1, for instance) is of course
passing string "foo" to set
set received string "foo"
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A workaround in the main program is to assign S to a local allocatable character variable and pass it instead:
use m1
character(:), allocatable :: ss
select type (s => get())
type is (character(*))
print *, 'passing string "', s, '" to set'
ss = s
call set(ss)
end select
end

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