- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the subject line supported in 11.1? If not, is it supported in the next (Novemberish) major release?
For example, the following dies at runtime using 11.1.067 with /check:all /warn:all with a "pointer ITEM ... not associated" error. But I think the code is legitimate.
[fortran]PROGRAM a_classy_assignment
IMPLICIT NONE
TYPE :: parent
INTEGER :: comp
END TYPE parent
TYPE wrapper
CLASS(parent), ALLOCATABLE :: item
END TYPE wrapper
TYPE(wrapper) :: a
TYPE(wrapper) :: b
!***
ALLOCATE(parent:: a%item)
a%item%comp = 123
b = a
PRINT "(I0)", a%item%comp ! 123
PRINT "(I0)", b%item%comp ! Boom.
END PROGRAM a_classy_assignment[/fortran]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...In an intrinsic assignment statement, variable shall not be polymorphic...
If I am not misreading this statement, line 14 of your program violates this rule. The compiler could flag this violation, instead of producing code that causes a run-time crash.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried the program with pointer checking in the next major release and it executed without error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Roll on November(ish)!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[fortran]>ifort /check:all /warn:all /standard-semantics poly-comp-assign.f90 Intel Visual Fortran Compiler XE for applications running on IA-32, Version 1 2.0.3.175 Build 20110309 Copyright (C) 1985-2011 Intel Corporation. All rights reserved. Microsoft Incremental Linker Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. -out:poly-comp-assign.exe -subsystem:console poly-comp-assign.obj>poly-comp-assign 123 0[/fortran]
(Expected 123 twice).
An alternative example: poly-comp-assign-2.f90
Larger examples show that all is not well in polymorphic component land. It's easy enough to work around the assignment issue above, but then I hit a memory leak that's got me stumped (calling deallocate on a polymorphic component doesn't deallocate that component?). Work around suggestions appreciated.
poly-comp-leak.f90
(I'd raise similar issues with finalisation of derived type components, if I had any confidence about my understanding of who/when and where such finalisation should occur...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you note, assignment to a polymorphic variable is not standard F2003 but is standard F2008. The Intel compiler does not support this yet, but fails to complain about a polymorphic component as it does for a polymorphic variable. I have reported this to developers as DPD200167981. I assume that we'll either implement the feature or give an error message.
I have not looked at your example of finalization, but I know there has been some vigorous debate among the standards committee members on this topic and I think interpretations have been submitted. When I get a chance I'll look into this further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To clarify - the assignment issue is as per your post #2 - the variable being assigned to is not polymorphic, but the variable has a component that is polymorphic. I think the behaviour is all well defined by F2003 given the excerpt you quoted. I can work around that by defining a "Clone" type bound procedure that simulates the assignment of the component.
The other example is a memory leak that occurs when polymorphic components are used. When you deallocate the parent (non-polymorphic) variable it doesn't appear that cleanup is done on the components. Perhaps this is related to http://software.intel.com/en-us/forums/showpost.php?p=101350.
I'll put the finalization stuff in another post, because that might have more to do with my language understanding than suspected compiler issues.
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page