error #6678: compiler defect with pointer assignment to a type-bound procedure returning a pointer

Submit New Article

February 11, 2010 7:00 PM PST



Reference Number : DPD200148269


Version : 11.1


Product : Intel Fortran Compiler


Operating System : All


Problem Description : A valid pointer assignment to a type-bound procedure returning a pointer may fail to compile. The compiler will incorrectly diagnose this as "error #6678: When the target is an expression it must deliver a pointer result."  The error can occur if the procedure is invoked through a type-compatible object using component selector syntax (% sign). 

A naive working example:

MODULE ArrayModule
IMPLICIT NONE

TYPE ArrayOps
INTEGER, DIMENSION(:), POINTER :: iArray
CONTAINS
PROCEDURE :: allocArray
PROCEDURE :: getSubArray
END TYPE ArrayOps

CONTAINS

SUBROUTINE allocArray(self, aSize)
CLASS(ArrayOps) :: self
INTEGER, INTENT(IN) :: aSize
ALLOCATE(self%iArray(aSize))
END SUBROUTINE allocArray

FUNCTION getSubArray(self, LB, UB)
CLASS(ArrayOps) :: self
INTEGER, INTENT(IN) :: LB, UB
INTEGER, DIMENSION(:), POINTER :: getSubArray
getSubArray => self%iArray(LB:UB)
END FUNCTION
END MODULE ArrayModule

PROGRAM getTypeBoundPtKB
USE ArrayModule
IMPLICIT NONE
TYPE(ArrayOps) :: aVar
INTEGER, DIMENSION(:), POINTER :: subArray
CALL aVar%allocArray(10)
#ifdef SHOW_BUG
subArray => aVar%getSubArray(2,5)
#else
subArray => getSubArray(aVar,2,5)
#endif
END PROGRAM getTypeBoundPtKB

The compiler will incorrectly diagnose this as error #6678:
>
ifort -V
Intel(R) Fortran Intel(R) 64 Compiler Professional for applications running on Intel(R) 64, Version 11.1

> ifort -fpp -DSHOW_BUG getTypeBoundPtKB.f90
getTypeBoundPtKB.f90(31): error #6678: When the target is an expression it must deliver a pointer result.
subArray => aVar%getSubArray(2,5)
---------------^
compilation aborted for getTypeBoundPtKB.f90 (code 1)
>

As a workaround, instead of using component selector syntax, explicitly pass the invoking object to the procedure.  The workaround is illustrated in the example:
subArray => getSubArray(aVar,2,5)

The example can be successfully compiled by not defining SHOW_BUG:
ifort -fpp getTypeBoundPtKB.f90


Resolution Status : This issue is resolved in the 11.1 update 6 compilers.  The fixed versions are:
w_cprof_p_11.1.065 (Windows*)
l_cprof_p_11.1.072 (Linux*)
m_cprof_p_11.1.088 (Mac OS X*)



[DISCLAIMER: The information on this web site is intended for hardware system manufacturers and software developers. Intel does not warrant the accuracy, completeness or utility of any information on this site. Intel may make changes to the information or the site at any time without notice. Intel makes no commitment to update the information at this site. ALL INFORMATION PROVIDED ON THIS WEBSITE IS PROVIDED "as is" without any express, implied, or statutory warranty of any kind including but not limited to warranties of merchantability, non-infringement of intellectual property, or fitness for any particular purpose. Independent companies manufacture the third-party products that are mentioned on this site. Intel is not responsible for the quality or performance of third-party products and makes no representation or warranty regarding such products. The third-party supplier remains solely responsible for the design, manufacture, sale and functionality of its products. Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. *Other names and brands may be claimed as the property of others.]


Do you need more help?


This article applies to: Intel® Fortran Compiler for Linux* Knowledge Base,   Intel® Fortran Compiler for Mac OS X* Knowledge Base,   Intel® Visual Fortran Compiler for Windows* Knowledge Base