Showing results for 
Search instead for 
Did you mean: 
Honored Contributor I

Parameterized Derived Types: a question on structure constructors for types with default values of parameters

Consider the following simple code involving a parameterized derived type (PDT):

program p

   implicit none

   type :: t(k)
      integer, kind :: k = 0
   end type
   !type(t) :: foo = t(k=0)()    ! <-- This works
   type(t) :: foo = t()          ! <-- This does not  
   print *, "foo%k = ", foo%k


end program p
Compiling with Intel(R) Visual Fortran Compiler [Intel(R) 64]...
p.f90(11): error #6197: An assignment of different structure types is invalid.   [FOO]
ifort: error #10298: problem during post processing of parallel object compilation
compilation aborted for p.f90 (code 1)

It would appear Intel Fortran development team's interpretation of the standard is type parameters must be declared with the type in a structure constructor - is this correct?  It does not seem right, but I could be wrong yet I couldn't find any supporting statement(s) or constraint(s) in the standard document (WD 1539-1 J3/10-007r1 for Fortran 2008, 24 Nov. 2010) in favor of Intel Fortran implementation.  All I find in relation to structure constructors points back to "derived-type-spec" which has the following: see the highlighted line 31 (i.e., point




0 Kudos
1 Reply

I think this is our error. As I see it, the problem with t() is trying to decide if the () is the type-param-spec-list or the component-spec-list. I think that if () is seen then that is always a component-spec-list, since the type-param-spec-list is not allowed to be empty. I'll send this on to the developers. DPD200415364

0 Kudos