Hi all,
while experimenting with ifort support for deferred length character (please, consider that my understanding of this feature is far from being good!) I see some errors for the following code depending on the compilation flags.
module m implicit none contains subroutine s(x,dims) class(*), allocatable, intent(out) :: x(:) integer, allocatable, intent(out) :: dims(:) allocate(dims(2)) dims(1) = 2 dims(2) = 4 allocate(character(len=dims(2))::x(dims(1))) ! no problems using len=4 select type(x); type is(character(len=*)) x = 'ABCD' end select end subroutine s end module m program test use m implicit none integer, allocatable :: d(:) class(*), allocatable :: t(:) call s(t,d) select type(t); type is(character(len=*)) write(*,*) t end select end program test
The results are:
1) no compiler flags: works as expected
$ ifort test.f90 -o test
$ ./test
ABCDABCD
2) with -check all: there is an error
$ ifort -check all -traceback test.f90 -o test
$ ./test
forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable DIMS when it is not allocated
Image PC Routine Line Source
test 0000000000405550 Unknown Unknown Unknown
test 0000000000402337 m_mp_s_ 4 test.f90
test 000000000040354C MAIN__ 28 test.f90
test 00000000004021FE Unknown Unknown Unknown
libc.so.6 00007F04B80A3DB5 Unknown Unknown Unknown
test 0000000000402109 Unknown Unknown Unknown
3) the error is slightly different including -standard-semantics
$ ifort -check all -traceback -standard-semantics test.f90 -o test
$ ./test
forrtl: severe (408): fort: (2): Subscript #1 of the array DIMS has value 2 which is greater than the upper bound of -1
Image PC Routine Line Source
test 0000000000405470 Unknown Unknown Unknown
test 000000000040242D m_MP_s_ 4 test.f90
test 0000000000403465 MAIN__ 28 test.f90
test 00000000004021FE Unknown Unknown Unknown
libc.so.6 00007F81EC70FDB5 Unknown Unknown Unknown
test 0000000000402109 Unknown Unknown Unknown
$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0 Build 20140723
Marco