Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Regression in 2025.2

NCarlson
New Contributor I
1,416 Views

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"

 

0 Kudos
1 Reply
NCarlson
New Contributor I
1,413 Views

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
0 Kudos
Reply