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

Using a character component of a type as an argument to a function accepting unlimited polymorphic type

pwl_b
Novice
333 Views
$ ifort --version
ifort (IFORT) 12.1.3 20120212

contents of test.f90:

[fortran]program test type :: tp character(len=18) :: name = "abc" integer :: int = 3 end type tp type(tp), target :: t class(*), pointer :: x character(len=17), target :: name = "efg" x => t%name call f(x) call f(t%name) x => t%int call f(x) call f(t%int) x => name call f(x) call f(name) contains subroutine f(x) class(*) :: x select type(x) type is (character(len=*)) print '(2g0)',"char=",x type is (integer) print '(2g0)',"int=",x end select end subroutine f end program test [/fortran]
$ifort -stand f08 -o test test.f90 && ./test
[plain]char=abc char= int=3 int=3 char=efg char=efg [/plain] Note the second line where 'char=' is not followed by 'abc'.

Is such behavior compliant with Fortran 2008 standard, or is it a bug in ifort?
0 Kudos
1 Reply
Steven_L_Intel1
Employee
332 Views
It's a bug, but one that we have fixed for a version to be released later this year.
0 Kudos
Reply