- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am playing around with assignment overloading. Here is the test:
[fortran]
MODULE COOS
TYPE POINT
REAL(KIND=8) :: COO(3) = [0.0D0,0.0D0,0.0D0]
END TYPE POINT
TYPE, EXTENDS(POINT) :: WAYPOINT
LOGICAL :: REFINE = .TRUE.
REAL(KIND=8) :: PATH_LENGTH = 0.0D0
END TYPE
INTERFACE ASSIGNMENT(=)
MODULE PROCEDURE POINT_ASSIGN
END INTERFACE
CONTAINS
SUBROUTINE COOS_UNIT_TEST_1()
IMPLICIT NONE
! Private variables
TYPE(POINT), ALLOCATABLE :: TEST_POINTS(:)
TYPE(WAYPOINT), ALLOCATABLE :: TEST_WAYPOINTS(:)
TYPE(POINT) :: TEST_POINT
TYPE(WAYPOINT) :: TEST_WAYPOINT
! Start work
ALLOCATE(TEST_WAYPOINTS(10))
ALLOCATE(TEST_POINTS(SIZE(TEST_WAYPOINTS)))
CALL POINT_ASSIGN(TEST_POINTS,TEST_WAYPOINTS)
CALL POINT_ASSIGN(TEST_POINT,TEST_WAYPOINT)
TEST_POINTS = TEST_WAYPOINTS
TEST_POINT = TEST_WAYPOINT
END SUBROUTINE COOS_UNIT_TEST_1
PURE ELEMENTAL SUBROUTINE POINT_ASSIGN(P_LHS,P_RHS)
IMPLICIT NONE
! Arguments
CLASS(POINT), INTENT(INOUT) :: P_LHS
CLASS(POINT), INTENT(IN) :: P_RHS
! Start work
SELECT TYPE(P_LHS)
TYPE IS (POINT)
SELECT TYPE(P_RHS)
TYPE IS (WAYPOINT)
P_LHS%COO = P_RHS%COO
END SELECT
END SELECT
END SUBROUTINE POINT_ASSIGN
END MODULE COOS
PROGRAM TEST
USE COOS
CALL COOS_UNIT_TEST_1()
END PROGRAM[/fortran]
Using ifort 13.1.2.183 Build 20130514, here is what I get:
[bash]$ ifort -g -traceback test.f90 ; ./a.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
libc.so.6 0000003822A78350 Unknown Unknown Unknown
a.out 0000000000403BFD coos_mp_point_ass 47 test.f90
a.out 0000000000403620 coos_mp_coos_unit 33 test.f90
a.out 0000000000403DCE MAIN__ 58 test.f90
a.out 0000000000402A5C Unknown Unknown Unknown
libc.so.6 0000003822A1D994 Unknown Unknown Unknown
a.out 0000000000402959 Unknown Unknown Unknown[/bash]
Note that the trace indicates the segfault happens at TYPE_IS(P_RHS) (the forum removed blank lines in the source), but only when using the '=' operator. The call to the same routine without going via the '=' interface has no problem. I tried with '-assume realloc_lhs' and got the same results.
The NAG fortran compiler (v 5.3.1) has no problem with this code.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting. I can reproduce the error with the x64 compiler but not the IA-32 compiler. I will investigate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On further analysis I can see the error with IA-32 as well. I have escalated this as issue DPD200244852 and will let you know of any progress. Thanks for the nice example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, thanks Steve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This has been fixed for a release later this year. We were not properly handling polymorphic dummy arguments in defined assignment routines.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page