- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe the following code is ok and it compiles with no errors or warnings. But it encounters a run-time error; it appears the automatic variable in the "contained" type that depends on the length parameter is not allocated.
module m implicit none private type :: t(n) private integer, len :: n = 1 integer :: m_a(n) end type t type, public :: q(l) private integer, len :: l = 1 type(t(n=l)) :: m_t end type q public :: init_q contains subroutine init_t(this) type(t(*)), intent(inout) :: this this%m_a = 1 print *, " t%a = ", this%m_a return end subroutine init_t subroutine init_q(this) type(q(*)), intent(inout) :: this call init_t(this%m_t) return end subroutine init_q end module m
program p use m, only : q, init_q type(q(l=:)), allocatable :: foo allocate( q(l=2) :: foo) call init_q(foo) stop end program p
Upon execution,
forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source p64.exe 000000013F8610F7 M_mp_INIT_T 27 m.f90 p64.exe 000000013F86125B M_mp_INIT_Q 39 m.f90 p64.exe 000000013F861585 MAIN__ 8 p.f90 p64.exe 000000013F8F319E Unknown Unknown Unknown p64.exe 000000013F8F392C Unknown Unknown Unknown p64.exe 000000013F8F3A6E Unknown Unknown Unknown kernel32.dll 00000000772359ED Unknown Unknown Unknown ntdll.dll 000000007736BA01 Unknown Unknown Unknown Press any key to continue . . .
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To stress the point about the ALLOCATABLE attribute, the program works without it.
program p use m, only : q, init_q type(q(l=2)) :: foo call init_q(foo) stop end program p
t%a = 1 1 Press any key to continue . . .
My apologies if this is a known issue; I couldn't be figure out for sure from the forum if an incident along these lines has been submitted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's a variation of the above problem with an extended type: please note the comment on line 25.
module m implicit none private type :: t(n) private integer, len :: n = 1 integer :: m_a(n) end type t type, extends(t), public :: q private end type q public :: init_q contains subroutine init_q(this) type(q(*)), intent(inout) :: this this%m_a = 1 !.. this%t%m_a = 1 works. return end subroutine init_q end module m
program p use m, only : q, init_q type(q(n=:)), allocatable :: foo allocate( q(n=2) :: foo ) call init_q(foo) stop end program p
forrtl: severe (157): Program Exception - access violation Image PC Routine Line Source p64.exe 000000013F5E10CD M_mp_INIT_Q 25 m.f90 p64.exe 000000013F5E135C MAIN__ 8 p.f90 p64.exe 000000013F66BF4E Unknown Unknown Unknown p64.exe 000000013F66C6DC Unknown Unknown Unknown p64.exe 000000013F66C81E Unknown Unknown Unknown kernel32.dll 00000000772359ED Unknown Unknown Unknown ntdll.dll 000000007736BA01 Unknown Unknown Unknown Press any key to continue . . .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please note another variation of the extended type case in Quote #3. With a statically declared variable, the program simply crashes without any run-time error:
program p use m, only : q, init_q !.. module m as in Quote #3; q is an extended type type(q(n=2)) :: foo call init_q(foo) stop end program p
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just trying to prevent this from falling off the radar; potentially a couple of issues with Intel Fortran compiler here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Whoops - thanks for the reminder. Will look at this tomorrow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Escalated as issue DPD200368557, and I included all variants. Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks much, Steve.
I am hoping the fixes for such issues will extend to type-bound procedures as well (you'll note the procedures in the snippets above are not type-bound). What I have posted here are the stripped down variants where the type binding has been removed, something I was trying out to further simplify the test cases. Since the run-time behavior appeared to be the same with or without type binding, I didn't bother submitting type-bound scenarios. Now I can test for this when the fixed releases become available, but it will be cool if the Intel development would be so kind to look into it during their resolution phase itself!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Type-bound procedures are really a completely different thing in the compiler, not that they're without issues on their own.
But when I see a fix internally for the PDT issues, I'll try some cases with TBPs and see if I can break them.

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