- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I run the code below (compiled with ifort 11.1 Update 4), I get 400 printed three times. Is it a bug, or is the compiler right at ignoring the initialization for a polymorphic argument?
!------------------------------------------------------------------------------
module mod1
implicit none
private
save
type, public :: t1
integer :: item = 300
contains
procedure :: destroy
end type
contains
subroutine destroy(this)
class(t1), intent(OUT) :: this
print *, this%item
end subroutine
end module mod1
program test
use mod1
implicit none
type(t1) :: a
continue
a%item = 400
print *, a%item
call a%destroy()
print *, a%item
end program test
!------------------------------------------------------------------------------
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
While Steve comes back with the authoritative answer, I looked through the F2003 handbook (by Adams et al) and 95/2003 book by Metcalf et al to see if there are any exceptions to the Intent(OUT) when the object is polymorphic. But I did not find any. It would be a surprise if there was.
On the other hand: On page 238, chapter 7, of the handbook by Adams a special note is made about vector v (which is a polymorphic argument) being deallocated on entry because it is intent(out). Thus, this is a compiler bug.
Unfortunately, since update 4 messes up the debugger, it is not possible to step into the type-bound procedure and see the value of the variable to look/verify the behavior of intent(OUT).
Abhi
p.s. for whatever it is worth, running this snippet with IBM XLF v11 gives: 400, 300, 300 which is the correct answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This was fixed in 13.0.

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