Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29487 Discussions

segfault on TYPE IS within assignment overloading routine

Alexis_R_
New Contributor I
796 Views

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.

0 Kudos
4 Replies
Steven_L_Intel1
Employee
796 Views

Interesting.  I can reproduce the error with the x64 compiler but not the IA-32 compiler. I will investigate.

0 Kudos
Steven_L_Intel1
Employee
796 Views

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.

0 Kudos
Alexis_R_
New Contributor I
796 Views

OK, thanks Steve.

0 Kudos
Steven_L_Intel1
Employee
796 Views

This has been fixed for a release later this year. We were not properly handling polymorphic dummy arguments in defined assignment routines.

0 Kudos
Reply