- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
here's an example demosntrating that double allocation of polymorphic variables does not cause a runtime error condition, as expected.
[fortran]
program p
type derived_type
integer, dimension(99) :: lost
end type
type(derived_type), allocatable :: my_static
class(derived_type), allocatable :: my_polymorphic
! runtime-check does not catch double allocation!
allocate(my_polymorphic, source = derived_type(1))
allocate(my_polymorphic, source = derived_type(1))
! runtime-check catches all following double allocations:
! forrtl: severe (151): allocatable array is already allocated
! allocate(my_polymorphic)
! allocate(my_polymorphic)
!
! allocate(my_static)
! allocate(my_static)
!
! allocate(my_static, source = derived_type(1))
! allocate(my_static, source = derived_type(1))
end program
[/fortran]
With regards,
Ferdinand
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PS:
Additional checks with valgrind show that, as demonstrated in the example, a memory leak might go unnoticed without a runtime error.
So that kind of error report (besides beeing defined by the standard as far as I know) is very important for debugging. Hence I would like to ask for that error condition to be raised even for polymorphic variables in future versions of ifort? (currently using 14.0.1).
Best Regards,
Ferdinand
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page