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

PARAMETER initialization fails when TYPE builds on an ABSTRACT class

Espen_M_
Beginner
462 Views

In my code I have some PARAMETERs of a derived type which builds on an ABSTRACT type/class with no components:

TYPE, ABSTRACT :: point
CONTAINS PROCEDURE :: dist => pt_to_pt_dist
END TYPE point

TYPE, EXTENDS(point) :: point2d
REAL, DIMENSION(2) :: c !coordinates: c(1) & c(2)
CONTAINS
PROCEDURE :: array_to_point2d
GENERIC :: ASSIGNMENT(=) => array_to_point2d
END TYPE point2d

The below declaration statement compiles without problems:
TYPE(point2d),PARAMETER :: apoint=point2d([ 2.0, 3.0 ])
However, if I then print the array apoint%c the actual values don't seem to be initialized at all, and seemingly random numbers are printed, as if it was an ordinary variable that wasn't initialized yet.
If I then change the point2d type to a 'stand-alone' type, ie. I remove the EXTENDS(point) attribute, everything works just fine.
I'm testing the IVF 2013 compiler right now, but I get the same strange behavior using the 2011 compiler.
Is it a compiler bug, or am I doing something wrong?

And I also want to ask if parameterized derived types are far away

0 Kudos
3 Replies
Steven_L_Intel1
Employee
462 Views
I'll take a look at your example tomorrow, but don't look for parameterized derived types anytime soon. I expect this will be the last 2003 feature we do.
0 Kudos
Steven_L_Intel1
Employee
462 Views
I have reproduced this and escalated it to the developers as issue DPD200238645. I will update this thread with any news. Thanks for taking the time to let us know of the problem.
0 Kudos
Steven_L_Intel1
Employee
462 Views

This has been fixed for a release later this year.

0 Kudos
Reply