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

Allocatable character - internal error

tplaakso
Beginner
492 Views
Hello,

I was trying to something like
[fortran]module mod

  type :: one
   contains
     procedure :: f
  end type one

contains

  integer function f(this)
    class(one) :: this
    f = 3
  end function f

end module mod

program test

  use mod

  character(:), allocatable :: a
  type(one) :: t

  allocate(character(t%f()) :: a)

end program test
[/fortran]
but this resulted in
[fortran][merry] misc > ifort -free intel_alloc_char_bug.f
intel_alloc_char_bug.f(24): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
  allocate(character(t%f()) :: a)
^
[ Aborting due to internal error. ]
compilation aborted for intel_alloc_char_bug.f (code 1)
[/fortran]
Does this has to do with parameterized derived-types not being supported yet? A simpler example works:
[fortran]program test

  character(:), allocatable :: a

  allocate(character(f()) :: a)

contains

  integer function f()
    f = 3
  end function f

end program test
[/fortran]
Teemu Laakso
0 Kudos
2 Replies
Steven_L_Intel1
Employee
492 Views
No, this is simply a compiler bug where it has trouble when a type-bound-procedure is in the length field. No relation to parameterized derived types. The following alternative works:

[fortran]program test

  use mod

  character(:), allocatable :: a
  type(one) :: t
  integer fx

  fx = t%f()

  allocate(character(fx) :: a)

end program test
[/fortran]
I will report this to the developers. Issue ID is DPD200176247.
0 Kudos
Steven_L_Intel1
Employee
492 Views
This has been fixed for a future version of the compiler.
0 Kudos
Reply