- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are several problems here I need to work through... I'll let you know what I find.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps it is significant/telling that the error is reported on line-4, the subroutine statement, rather than later. When execution reaches this line, the output array dims has neither been allocated nor initialized, and the compiler seems to be unable to set up the stack.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The INTENT(OUT) is probably involved to some extent - the compiler is incorrectly doing bounds and pointer checking on the unallocated dummy argument - I have a faint memory of a similar issue being reported before. Stay tuned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, it's not the INTENT(OUT). What is particularly interesting about this program is that if you compile it with no options, that is, with optimization, it works, but when I tried it with optimization disabled, I got a segfault! Either one of the arguments seems to trigger the problem.
I have escalated this to development as issue DPD200363248. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, thank you. (By the way, it helps so much that you report the tracking code and later on when things get fixed!)
Marco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This has been fixed in our sources. I expect the fix to appear in Update 2, planned for February.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page