- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler error with the following code appears to be incorrect:
module m implicit none private type, public :: t private integer, pointer :: m_i contains private procedure, pass(this), public :: iptr => getptr procedure, pass(this), public :: setptr end type t contains subroutine setptr( this, iptr ) !.. Argument list class(t), intent(inout) :: this integer, pointer, intent(inout) :: iptr this%m_i => iptr return end subroutine setptr function getptr( this ) result( iptr ) !.. Argument list class(t), intent(in) :: this !.. Function result integer, pointer :: iptr iptr => this%m_i return end function getptr end module m
program p use m, only : t integer, pointer :: i type(t) :: foo print *, " Is i associated with foo%iptr? ", associated( i, foo%iptr() ) stop end program p
Compiling with Intel(R) Visual Fortran Compiler XE 15.0.4.221 [Intel(R) 64]... p.f90 C:\..\p.f90(8): error #6808: The TARGET argument must have the POINTER or TARGET attribute. [ASSOCIATED] compilation aborted for C:\..\p.f90 (code 1)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FWIW, Compiler 15.0, update 2 gives the same error as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And just to show it is a problem with the type-bound aspect of the type, code compiles and works ok with the following simple change:
module m implicit none private type, public :: t private integer, pointer :: m_i contains private procedure, pass(this), public :: iptr => getptr procedure, pass(this), public :: setptr end type t public :: getptr contains subroutine setptr( this, iptr ) !.. Argument list class(t), intent(inout) :: this integer, pointer, intent(inout) :: iptr this%m_i => iptr return end subroutine setptr function getptr( this ) result( iptr ) !.. Argument list class(t), intent(in) :: this !.. Function result integer, pointer :: iptr iptr => this%m_i return end function getptr end module m
program p use m, only : t, getptr integer, pointer :: i type(t) :: foo !.. create i with some value allocate(i, source=42) call foo%setptr( i ) print *, " Is i associated with getptr( foo )? ", associated( i, getptr( foo ) ) print *, " getptr( foo ) = ", getptr( foo ) print *, " foo%iptr() = ", foo%iptr() stop end program p
Upon execution,
Is i associated with getptr( foo)? T getptr( foo ) = 42 foo%iptr() = 42 Press any key to continue . . .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you FortranFan for all the details. I reported this to our Developers and will keep you updated about what I hear back.
(Internal tracking id: DPD200374298)
(Resolution Update on 02/27/2016): This defect is fixed in the Intel® Parallel Studio XE 2016 Update 2 Release (PSXE 2016.2.055/ CnL 2016.2.180 - Windows)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Kevin, for your prompt follow-up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The erroneous error noted in post #1 is fixed in the latest PSXE 2016 Update 2 release (PSXE 2016.2.055/ CnL 2016.2.180 - Windows)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kevin Davis (Intel) wrote:
The erroneous error noted in post #1 is fixed in the latest PSXE 2016 Update 2 release (PSXE 2016.2.055/ CnL 2016.2.180 - Windows)
Thanks, Kevn, for the update - I've confirmed the fix.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page